You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50ae23c9e9 | 11 years ago | |
---|---|---|
README.md | 11 years ago | |
decode.js | 11 years ago | |
encode.js | 11 years ago | |
index.js | 11 years ago | |
package.json | 11 years ago | |
test.js | 11 years ago |
README.md
varint
encode whole numbers to an array of protobuf-style varint bytes and also decode them.
var varint = require('varint')
var bytes = varint.encode(300) // === [0xAC, 0x02]
varint.decode(bytes) // [300, 2]
api
varint = require('varint')
varint.encode(num[, output=[], offset=0]) -> array
encodes num
into either the array given by offset
or a new array at offset
and returns that array filled with integers.
varint.decode(data[, offset=0]) -> [number, length]
decodes data
, which can be either a buffer or array of integers, from position offset
or default 0 and returns an array containing [number, length]
where number is the original integer and length is the amount of bytes that were consumed in order to decode the number
License
MIT