Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
A simple set of functions for converting between integer and VLQ buffer values
A simple set of functions for converting between integer and VLQ buffer values
$ npm install --save vlq-buffer
var vlqBuffer = require('vlq-buffer');
This method converts an integer to a Buffer containing the VLQ representation of that integer.
var myInt = 2097151;
var bufferValue = vlqBuffer.int2VLQBuffer(myInt);
// bufferValue == <Buffer ff ff 7f>
This method converts a Buffer containing a VLQ value to an integer.
var myVLQValue = new Buffer([0x81, 0x80, 0x00]);
var intValue = vlqBuffer.vlqBuffer2Int(myVLQValue);
// intValue == 16384
This method returns true if the given integer's binary value starts with zero, indicating tne end of the VLQ value. This is useful for identifying the final byte in a VLQ value when reading binary data.
var vlqStartIndex = readIndex; // start reading a vlq value and the current read index
var currentByte = bufferData.readUInt8(readIndex);
while (!vlqBuffer.isVLQLastByte(currentByte)) {
if (++readIndex >= bufferData.length) throw 'EOF error'; // EOF, no vql end found
currentByte = bufferData.readUInt8(readIndex);
}
var vlqValueBytes = bufferData.slice(vlqStartIndex, ++readIndex);
var intValue = vlq.vlqBuffer2Int(vlqValueBytes);
FAQs
A simple set of functions for converting between integer and VLQ buffer values
We found that vlq-buffer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.