Registry / serialization / buffer-builder

buffer-builder

JSON →
library0.2.0jsnpmunverified

This package, `buffer-builder`, provides a utility for incrementally constructing a Node.js `Buffer` without prior knowledge of its final size. It offers methods to append strings, existing buffers, and various integer/float types (e.g., `appendUInt32LE`, `appendFloatBE), as well as a byte fill operation. The current stable version is 0.2.0, last published over a decade ago in January 2015. Due to its age, it directly relies on the now-deprecated `new Buffer()` constructor, which poses significant security and usability issues in modern Node.js environments. This package is effectively abandoned, with no active development or updates to address compatibility with contemporary Node.js Buffer APIs (like `Buffer.from`, `Buffer.alloc`). Developers seeking similar functionality should consider actively maintained alternatives or Node.js's built-in `Buffer.concat` with an array of smaller buffers.

npm install buffer-builder
INSTALL
IMPORT
SIG · BUFFER-BUILDER
B
buffer-builder
serializationjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BufferBuilder
import BufferBuilder from 'buffer-builder';
const BufferBuilder = require('buffer-builder');
While CommonJS `require` is shown in the original documentation, modern Node.js projects typically use ESM `import`. This package was published before widespread ESM adoption, so direct ESM compatibility may be limited without a transpilation layer. However, Node.js allows `import` of CJS modules.
Buffer
import { Buffer } from 'node:buffer';
const Buffer = require('buffer');
This package relies heavily on the global `Buffer` object or `require('buffer')`. For explicit import and modern Node.js practices, use `import { Buffer } from 'node:buffer';`. Be aware that the package's internal use of `new Buffer()` is deprecated.

Demonstrates initializing BufferBuilder, appending various data types, and retrieving the final Buffer, updated for modern Node.js Buffer API usage.

import BufferBuilder from 'buffer-builder'; import { Buffer } from 'node:buffer'; const 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 - using Buffer.from() for modern Node.js compatibility helloWorld.appendBuffer(Buffer.from([111, 114, 108, 100])); // Appended a repetition of a byte helloWorld.appendFill(33, 3); // Convert to an ordinary buffer const buffer = helloWorld.get(); console.log(buffer.toString()); // Expected: hello world!!!
Debug
Known issues
breakingThe `buffer-builder` package internally uses `new Buffer()`, which was deprecated in Node.js v6.0.0 and removed in v10.0.0. Using this package with Node.js v10 or newer will cause runtime errors because `Buffer` is no longer a constructor.
fix
This package is effectively abandoned. For projects requiring Node.js v10+, consider alternative buffer building libraries or use native `Buffer.alloc()`, `Buffer.from()`, and `Buffer.concat()` with an array of buffers. If you must use this package with older Node.js versions, ensure your project's Node.js runtime is <10.0.0.
affects: >=10.0.0
gotchaThe package has not been updated since January 2015, making it highly susceptible to compatibility issues with newer Node.js versions, security vulnerabilities discovered since its last release, and lack of modern JavaScript features (e.g., ESM).
fix
It is strongly recommended to migrate away from this package to actively maintained alternatives. If unable to migrate, thoroughly audit the package for security vulnerabilities and test rigorously with your specific Node.js version.
affects: >=0.2.0
deprecatedThe documentation's usage example uses `new Buffer([...])`. This method creates an uninitialized buffer which can expose sensitive memory contents and is a security risk.
fix
Always use `Buffer.from()` when creating a buffer from data (e.g., `Buffer.from([111, 114, 108, 100])`) or `Buffer.alloc()` for a zero-filled buffer of a specific size (e.g., `Buffer.alloc(10)`). The quickstart code reflects this change.
affects: >=0.2.0
Errors
Common errors & fixes
TypeError: Buffer is not a constructor
Attempting to instantiate `Buffer` using `new Buffer()` in Node.js v10.0.0 or later, which removed the `Buffer` constructor. This package internally uses `new Buffer()` which leads to this error.
fix
This package is incompatible with Node.js v10+. Either downgrade your Node.js version (not recommended) or replace `buffer-builder` with an actively maintained alternative that uses `Buffer.from()` or `Buffer.alloc()`.
(node:XXXX) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Running `buffer-builder` with Node.js v6.0.0 through v9.x.x. The package uses `new Buffer()` which is formally deprecated during this range.
fix
This warning indicates the package uses an outdated and potentially insecure API. While it might still function, it's a strong signal to migrate to a modern, actively maintained buffer building library to avoid future breaking changes and security risks. You can suppress the warning with `--no-deprecation` but this is not recommended.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
buffer-builder — npm install buffer-builder · libregistry