
Product
Announcing Bun and vlt Support in Socket
Bringing supply chain security to the next generation of JavaScript package managers
leb128
Advanced tools
This gem is a set of utility functions for encoding and decoding LEB128-compressed integers.
As a visual example, this is an excerpt from the LEB128 Wikipedia page describing how an integer is encoded into an unsigned LEB128:
10011000011101100101 In raw binary
010011000011101100101 Padded to a multiple of 7 bits
0100110 0001110 1100101 Split into 7-bit groups
00100110 10001110 11100101 Add high 1 bits on all but last group to form bytes
0x26 0x8E 0xE5 In hexadecimal
0xE5 0x8E 0x26 Output stream
Add this line to your application's Gemfile:
gem 'leb128'
And then execute:
$ bundle
Or install it yourself as:
$ gem install leb128
Require the Gem:
require 'leb128'
Encode integers into LEB128-compressed data by using the encode_unsigned and encode_signed methods. The functions take one argument, being the integer to encode. The following encodes the given integer and returns a new StringIO containing it:
LEB128.encode_signed(-0x143f)
#=> #<StringIO:0x00000000000000>
Decode LEB128-compressed data into integers by using the decode_unsigned and decode_signed methods. The functions take two arguments: a StringIO containing the LEB128-compressed data, and an optional integer that sets the position of the StringIO (default is 0). The following decodes the given StringIO and returns a new integer containing it:
sio = StringIO.new
sio.putc(0xc1)
sio.putc(0x57)
LEB128.decode_unsigned(sio)
#=> 11201
This gem is available as open source under the terms of the MIT License. See LICENSE.md and https://opensource.org/licenses/MIT.
FAQs
Unknown package
We found that leb128 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.