Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
buffer-builder
Advanced tools
BufferBuilder accumulates pieces of data into a buffer, appending each onto the end. The data can be Buffers, strings, a repetition of a byte, or any of the types such as UInt32LE or FloatBE that can be written into Buffers.
If you are thinking about using this, you should probably have considered streaming your data instead of putting it into a buffer.
var BufferBuilder = require('buffer-builder');
var helloWorld = new BufferBuilder();
// Append a string, utf8 encoded by default.
helloWorld.appendString('hello');
// Append any type that Buffer has read and write functions for.
helloWorld.appendUInt16LE(0x7720);
// Append a buffer
helloWorld.appendBuffer(new Buffer([111, 114, 108, 100]));
// Appended a repetition of a byte
helloWorld.appendFill(33, 3);
// Convert to an ordinary buffer
var buffer = helloWorld.get();
buffer.toString(); // hello world!!!
Allocate an empty BufferBuilder. If you know approximately what size the Buffer will end up being and are trying to squeeze out more performance, you can set the initial size of the backing buffer.
Append a buffer. Use slice if you want to append just part of one.
Append a string, encoded by utf8 by default. No trailing 0 is appended.
Append a null-terminated string, encoded by utf8 by default.
Append 8-bit unsigned integer.
Append 16-bit unsigned integer, little endian. 1 is encoded as 01 00.
Append 16-bit unsigned integer, big endian. 1 is encoded as 00 01.
Append 32-bit unsigned integer, little endian. 1 is encoded as 01 00 00 00.
Append 32-bit unsigned integer, big endian. 1 is encoded as 00 00 00 01.
Append 8-bit signed integer.
Append 16-bit signed integer, little endian. 1 is encoded as 01 00.
Append 16-bit signed integer, big endian. 1 is encoded as 00 01.
Append 32-bit signed integer, little endian. 1 is encoded as 01 00 00 00.
Append 32-bit signed integer, big endian. 1 is encoded as 00 00 00 01.
Little-endian float. Occupies 4 bytes.
Big-endian float. Occupies 4 bytes.
Little-endian double. Occupies 8 bytes.
Big-endian double. Occupies 8 bytes.
Append count repetitions of value (a byte).
Convert to a buffer. This is a deep copy; modifications to the returned buffer will not affect the BufferBuilder.
Copy bytes from the BufferBuilder into targetBuffer. targetStart and sourceStart default to 0. sourceEnd defaults to the BufferBuilder's length.
Number of bytes appended so far.
FAQs
Build a buffer without knowing its size beforehand
The npm package buffer-builder receives a total of 0 weekly downloads. As such, buffer-builder popularity was classified as not popular.
We found that buffer-builder 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.