@uttori/data-tools
Version:
Tools for working with binary data.
80 lines (57 loc) • 2.65 kB
Markdown
[](https://www.npmjs.com/package/@uttori/data-tools)
[](https://www.npmjs.com/package/@uttori/data-tools)
[](https://travis-ci.com/uttori/uttori-data-tools)
[](https://coveralls.io/r/uttori/uttori-data-tools?branch=master)
[](https://bundlephobia.com/result?p=@uttori/data-tools)
[](https://bundlephobia.com/result?p=@uttori/data-tools)
[](https://bundlephobia.com/result?p=@uttori/data-tools)
[](https://bundlephobia.com/result?p=@uttori/data-tools)
# 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
```bash
npm install --save @uttori/data-tools
```
* * *
## Examples
```js
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](https://rollupjs.org/), you will likely want to use `replace()` of [@rollup/plugin-replace](https://www.npmjs.com/package/@rollup/plugin-replace) like the following example to get a clean output:
```js
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`:
```bash
npm install
npm test
DEBUG=Uttori* npm test
```
## Contributors
- [Matthew Callis](https://github.com/MatthewCallis)
## License
- [MIT](LICENSE)