How to use the varint.decode function in varint

To help you get started, we’ve selected a few varint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skale-me / node-parquet / lib / parquet.js View on Github external
function rleDecode(buf, offset, datalen, bitWidth) {
  var header = varint.decode(buf, offset);
  var count = header >>> 1;

  datalen -= varint.decode.bytes;
  if (header & 1) { // Bit packed
    console.log('read ' + (count * 8) + ' bit packed values');
  } else {          // RLE
    console.log('read ' + count + ' RLE values');
    console.log('remain ' + datalen + ' bytes');
  }
}
github mafintosh / protocol-buffers / decoder.js View on Github external
return function(obj, buf, offset) {
					var len = varint.decode(buf, offset);
					offset += varint.decode.bytesRead;
					var end = offset + len;
					obj[key] = [];
					while (offset < end) {
						var next = {};
						obj[key].push(next);
						var itemLen = varint.decode(buf, offset);
						offset += varint.decode.bytesRead;
						offset = dec(next, buf, offset, offset, offset+itemLen);
					}
					return offset;
				};
			};
github mafintosh / derived-key-storage / index.js View on Github external
nameStorage.read(0, st.size, (err, buf) => {
          if (err) return cb(err, null)
          let len = 0

          try {
            len = varint.decode(buf, 0)
          } catch (err) {
            return cb(null, null)
          }

          const offset = varint.decode.bytes
          if (offset + len !== buf.length) return cb(null, null)
          const name = buf.slice(offset)
          return cb(null, name)
        })
      })
github mafintosh / stream-channels / index.js View on Github external
function decodeVarint (buf, offset) {
  try {
    return varint.decode(buf, offset)
  } catch (err) {
    return -1
  }
}
github mafintosh / hypergraph / index.js View on Github external
function unpackArray (buf) {
  var offset = 0
  var arr = []
  while (offset < buf.length) {
    arr.push(varint.decode(buf, offset))
    offset += varint.decode.bytes
  }
  return arr
}
github alanhoff / node-bolty / lib / decoders.js View on Github external
exports.varint = function(buff) {
  return varint.decode(buff);
};
github alanhoff / node-bolty / dist / bolty.js View on Github external
exports.varint = function(buff) {
  return varint.decode(buff);
};
github alanhoff / node-bolty / dist / bolty-bundle.js View on Github external
exports.varint = function(buff) {
  return varint.decode(buff);
};

varint

protobuf-style varint bytes - use msb to create integer values of varying sizes

MIT
Latest version published 4 years ago

Package Health Score

68 / 100
Full package analysis

Popular varint functions