日本語のREADMEはこちらです: README.ja.md
A set of utility functions for handling binary data in JavaScript.
bin2short,short2bin: Convert between 16-bit short integers and binary databin2i,i2bin: Convert between 32-bit integers and binary datasubbin: Extract a subset of binary datasetbin: Set a portion of binary databincat: Concatenate multiple binary dataeqbin: Compare binary data for equality
The binutil library is available as a set of standalone functions that can be imported and used in your JavaScript project.
import { bin2short, short2bin, i2bin, bin2i, bincat, eqbin, setbin, subbin } from 'binutil';The library also includes BinWriter and BinReader classes, which provide a more object-oriented interface for working with binary data.
import { BinWriter, BinReader } from 'binutil';
const writer = new BinWriter();
writer.writeUint32(123456);
writer.writeBytes(new Uint8Array([1, 2, 3]));
const data = writer.toBytes();
const reader = new BinReader(data);
const num = reader.readUint32();
const bytes = reader.readBytes(3);MIT License — see LICENSE.