numcodecs.js
Buffer compression and transformation codecs for use in Zarr.js and beyond...
Installation
npm install numcodecs
Usage
import { Blosc, GZip, Zlib, LZ4, Zstd } from 'numcodecs';
const codec = new Blosc();
const size = 100000;
const arr = new Uint32Array(size);
for (let i = 0; i < size; i++) {
arr[i] = i;
}
const bytes = new Uint8Array(arr.buffer);
console.log(bytes);
const encoded = await codec.encode(bytes);
console.log(encoded);
const decoded = await codec.decode(encoded);
console.log(new Uint32Array(decoded.buffer));
Author's note
This project is an incomplete TypeScript implementation of the buffer compression library
numcodecs
. The following codecs
are currently supported:
Package exports
Each compressor is bundled as the default export of separate code-split submodules.
This makes it easy to import each module independently in your applications or from
a ESM-friendly CDN like skypack.
import { Zlib } from 'numcodecs';
import Zlib from 'numcodecs/zlib';
import { Zlib } from 'https://cdn.skypack.dev/numcodecs';
import Zlib from 'https://cdn.skypack.dev/numcodecs/zlib';
Development
$ git clone https://github.com/manzt/numcodecs.js.git
$ cd numcodecs.js
$ npm install && npm run test
The <codec_name>.js
+ <codec_name>.wasm
source for each WASM-based codec are
generated with Docker with the following commands:
cd codecs/<codec_name>
npm run build
Changelogs
For changes to be reflected in package changelogs, run npx changeset
and
follow the prompts.
Note not every PR requires a changeset. Since changesets are focused on
releases and changelogs, changes to the repository that don't effect these
won't need a changeset (e.g., documentation, tests).
Release
The Changesets GitHub action will create
and update a PR that applies changesets and publishes new versions.