`bytesish` (current stable version 0.4.4) is a utility library designed to simplify cross-platform binary data handling in JavaScript applications, specifically targeting environments compatible with both Node.js and browsers. It addresses the complexity of dealing with disparate binary types like Node.js `Buffer` and various browser `ArrayBufferView` types (e.g., `Uint8Array`) by providing a consistent `DataView` interface without introducing large polyfills. The library's core differentiator is its focus on zero-copy conversions to and from `DataView` whenever possible, minimizing memory overhead and bundle size. It offers utilities for converting between binary types and strings (with various encodings), comparison, sorting, slicing, and concatenating binary data. `bytesish` does not create a new binary data type but leverages `DataView` for direct manipulation, aiming to be a lightweight helper for common binary operations that are otherwise difficult to implement cross-platform.
npm install bytesishVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic instantiation, zero-copy conversions from various binary types, string encoding/decoding, and key utility functions like `native`, `slice`, and `concat`.
Always check whether an API is 'Zero Copy' or 'Memory Copy' in the documentation to understand its performance characteristics, especially in performance-critical loops or large data operations.
Use `bytes.native(dataView)` (for `Buffer` in Node.js) or `bytes.typedArray(dataView, Uint8Array)` (for `Uint8Array`) to convert the `DataView` to the platform's ideal binary type before passing to external functions.
Review the changelog carefully when upgrading to new 0.x versions and consider pinning to exact versions in production environments to avoid unexpected breaking changes.
Convert the `DataView` to the expected native type using `bytes.native(myView)` for Node.js `Buffer` or `bytes.typedArray(myView, Uint8Array)` for a `Uint8Array` before passing it to the external API.
Ensure the `encoding` argument matches one of the supported standard encodings (e.g., 'utf8', 'hex', 'base64', 'ascii', 'latin1').
No dependency data recorded yet.