From 76bbd6ee4bec6ff9f3ff2ed5ad55fd59ff9363ac Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Fri, 9 May 2014 00:36:54 +0200 Subject: [PATCH] document encodingLength --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d2c7fd8..df72382 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,11 @@ if you also require the length (number of bytes) that were required to decode th similar to `bytesRead` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array). you can access this via `varint.encode.bytesWritten` which holds the number of bytes written in the last encode. + +### varint.encodingLength(num) + +returns the number of bytes this number will be encoded as, up to a maximum of 8. + ## usage notes if you are using this to decode buffers from a streaming source it's up to you to make sure that you send 'complete' buffers into `varint.decode`. the maximum number of bytes that varint will need to decode is 8, so all you have to do is make sure you are sending buffers that are at least 8 bytes long from the point at which you know a varint range begins.