日本語の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';constwriter=newBinWriter();writer.writeUint32(123456);writer.writeBytes(newUint8Array([1,2,3]));constdata=writer.toBytes();constreader=newBinReader(data);constnum=reader.readUint32();constbytes=reader.readBytes(3);MIT License — see LICENSE.