@uttori/data-tools

Tools for working with binary data.

Usage no npm install needed!

<script type="module">
  import uttoriDataTools from 'https://cdn.skypack.dev/@uttori/data-tools';
</script>

README

view on npm npm module downloads Build Status Dependency Status Coverage Status Tree-Shaking Support Dependency Count Minified + GZip Minified

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

const { CRC32, DataBuffer, DataBufferList, DataBitstream, DataStream } = require('uttori-data-tools');

const CRC32 = require('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 need to at the very least use commonjs() of @rollup/plugin-commonjs and will likely want to use replace() of @rollup/plugin-replace like the following example to get a clean output:

rollup.rollup({
  input: './you-entry-file.mjs',
  plugins: [
  replace({
    'process.env.UTTORI_DATA_DEBUG': 'false',
  }),
  commonjs(),
  ],
});

Tests

To run the test suite, first install the dependencies, then run npm test:

npm install
npm test
DEBUG=Uttori* npm test

Contributors

License