
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
@remotex-labs/xbuffer
Advanced tools
xBuffer
xBuffer is a lightweight JavaScript library that provides buffer-like functionality for browsers, similar to Node.js's Buffer
.
It offers efficient manipulation of binary data and supports common encoding and decoding operations, such as base64, hex, and UTF-8.
Buffer
.Buffer
API pattern from Node.js, offering familiar methods for developers transitioning between the browser and Node.js environments.Uint8Array
, ensuring high performance and a small footprint in web environments.To install xBuffer
, use either npm or yarn:
npm install @remotex-labs/xbuffer
# or
yarn add @remotex-labs/xbuffer
# Usage
## Creating a Buffer
```typescript
import { Buffer } from '@remotex-labs/xbuffer';
// Create a buffer from a string
const buffer = Buffer.from('Hello, world!', 'utf-8');
// Create a buffer from an array of bytes
const byteArray = new Uint8Array([72, 101, 108, 108, 111]);
const bufferFromArray = Buffer.from(byteArray);
You can use xBuffer
for common encoding and decoding tasks, such as converting binary data to base64 or hex:
// Encode a buffer to base64
const base64String = buffer.toString('base64');
// Decode base64 to a buffer
const decodedBuffer = Buffer.from(base64String, 'base64');
// Encode a buffer to hex
const hexString = buffer.toString('hex');
// Decode hex to a buffer
const decodedHexBuffer = Buffer.from(hexString, 'hex');
setGlobalBuffer
This function sets the global Buffer
object on globalThis
, making it available throughout the environment. It is useful when Buffer
is not natively available, such as in certain browser contexts.
import { setGlobalBuffer } from '@remotex-labs/xbuffer';
// Set `Buffer` globally
setGlobalBuffer();
// Now `Buffer` is accessible globally
console.log(Buffer); // Logs the global Buffer object
supportUtilInspect
This function modifies the global console.log
to support custom inspection of objects that implement the util.inspect.custom
symbol.
It enables objects with custom inspection methods to be logged with their custom output.
import { supportUtilInspect } from '@remotex-labs/xbuffer';
// Enable custom inspect support
supportUtilInspect();
// Example object with custom inspection logic
const myObject = {
[Symbol.for('nodejs.util.inspect.custom')]: () => 'Custom inspection logic here',
};
// Log the object
console.log(myObject); // Logs: "Custom inspection logic here"
For performance comparisons between xBuffer and other buffer libraries, you can check the libs:
To build the benchmark project:
cd ./benchmark
docker build -t benchmark .
To run the benchmark:
docker run -it benchmark
Contributions are welcome! If you'd like to improve xBuffer
, feel free to open an issue or submit a pull request.
FAQs
A library with Node.js Buffer api for the browser
We found that @remotex-labs/xbuffer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.