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.

720 B

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

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

decodes data, which can be either a buffer or array of integers, from position offset or default 0 and returns the decoded integer

License

MIT