@uttori/data-tools
v3.1.1
Published
Tools for working with binary data.
Downloads
160
Maintainers
Readme
Uttori Data Tools
Tools for working with binary data.
- CRC32 - Derive the Cyclic Redundancy Check of a data blob.
- DataStream - Helpter class to ease parsing binary formats.
- DataBuffer - Helper class for working with binary data.
- DataBufferList - A linked list of DataBuffers.
- DataBitstream - Read a DataStream as a stream of bits.
Install
npm install --save @uttori/data-tools
Examples
import { CRC32, DataBuffer, DataBufferList, DataBitstream, DataStream } from 'uttori-data-tools';
CRC32.of('The quick brown fox jumps over the lazy dog');
➜ '414FA339'
const stream_a = DataStream.fromData(Buffer.from([20, 29, 119]));
const stream_b = DataStream.fromData(Buffer.from([20, 29, 119]));
stream_a.compare(stream_b);
➜ true
const buffer = new DataBuffer(data);
const list = new DataBufferList();
list.append(buffer);
Tree Shaking with ESM Modules
To enable tree-shaking with RollUp, you will likely want to use replace()
of @rollup/plugin-replace like the following example to get a clean output:
rollup({
input: './you-entry-file.js',
plugins: [
replace({
'process.env.UTTORI_DATA_DEBUG': 'false',
}),
],
});
Tests
To run the test suite, first install the dependencies, then run npm test
:
npm install
npm test
DEBUG=Uttori* npm test