Skip to content
/ varint Public

An Elixir library to compress integers using the Variable Length Encoding LEB128 compression.

License

Notifications You must be signed in to change notification settings

ahamez/varint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Varint

Elixir CI Coverage Status Hex.pm Hex Docs License

A library to compress integers using LEB128.

Installation

Add :varint to your list of dependencies in mix.exs:

def deps do
  [{:varint, "~> 1.4"}]
end

Usage

LEB128

Use this module to compress and decompress unsigned integers:

iex> Varint.LEB128.encode(300)
<<172, 2>>
iex> Varint.LEB128.decode(<<172, 2>>)
{300, <<>>}

Zigzag

As LEB128 works with unsigned integers, you can use the the Zigzag module to process signed integers.

iex> Varint.Zigzag.encode(-2)
3
iex> Varint.Zigzag.decode(3)
-2
iex> Varint.Zigzag.encode(2)
4
iex> Varint.Zigzag.decode(4)
2

You'll find detailed instructions at hexdocs.pm.

License

Copyright (c) 2016 Alexandre Hamez

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE file for more details.

About

An Elixir library to compress integers using the Variable Length Encoding LEB128 compression.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 4

  •  
  •  
  •  
  •  

Languages