decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer.
decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer.
Throws a `RangeError` when `data` does not represent a valid encoding.
### varint.decode.bytes
### varint.decode.bytes
if you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`. this is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode.
if you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`. this is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode.
@ -41,7 +43,7 @@ returns the number of bytes this number will be encoded as, up to a maximum of 8
## usage notes
## usage notes
If varint is passed a buffer that does not contain a valid end
If varint is passed a buffer that does not contain a valid end
byte, then `decode` will return undefined, and `decode.bytes`
byte, then `decode` will throw `RangeError`, and `decode.bytes`
will be set to 0. If you are reading from a streaming source,
will be set to 0. If you are reading from a streaming source,
it's okay to pass an incomplete buffer into `decode`, detect this
it's okay to pass an incomplete buffer into `decode`, detect this