# numcodecs

> Buffer compression and transformation codecs for use in data storage and communication applications.

Latest version **0.3.2** (published 2024-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install numcodecs
pnpm add numcodecs
yarn add numcodecs
bun add numcodecs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2024-08-14 |
| First published | 2020-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 38 |
| Author | Trevor Manz |
| Maintainers | manzt |
| Keywords | zarr, compression, codecs, storage |

## Links

- npm: https://www.npmjs.com/package/numcodecs
- Repository: https://github.com/manzt/numcodecs.js
- Homepage: https://github.com/manzt/numcodecs.js#readme
- Issues: https://github.com/manzt/numcodecs.js/issues
- npm.io page: https://npm.io/package/numcodecs

## Dependencies (1)

- [fflate](https://npm.io/package/fflate.md) ^0.8.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2024-08-14
- 0.2.0-alpha.2 (next) — 2020-12-27
- 0.3.1 — 2023-12-18
- 0.3.0 — 2023-12-16
- 0.2.2 — 2021-09-29
- 0.2.1 — 2021-05-03
- 0.2.0 — 2020-12-28
- 0.2.0-alpha.1 — 2020-12-23
- 0.2.0-alpha.0 — 2020-12-23
- 0.1.1 — 2020-07-12
- 0.1.0 — 2020-05-24
- 0.0.15 — 2020-05-15
- 0.0.14 — 2020-05-14
- 0.0.13 — 2020-05-05
- 0.0.12 — 2020-05-05
- … 3 more at https://npm.io/package/numcodecs/versions

## README

# numcodecs.js
[![Actions Status](https://github.com/manzt/numcodecs.js/workflows/tests/badge.svg)](https://github.com/manzt/numcodecs.js/actions)
[![NPM badge](https://img.shields.io/npm/v/numcodecs)](https://www.npmjs.com/package/numcodecs)

Buffer compression and transformation codecs for use in [Zarr.js](https://github.com/gzuidhof/zarr.js/) and beyond...

### Installation

```bash
npm install numcodecs
```

### Usage

```javascript
import { Blosc, GZip, Zlib, LZ4, Zstd } from 'numcodecs';

const codec = new Blosc();
// or Blosc.fromConfig({ clevel: 5, cname: 'lz4', shuffle: Blosc.SHUFFLE, blocksize: 0 });

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);
// Uint8Array(400000) [0, 0, 0, 0,  1, 0, 0, 0,  2, 0, 0, 0, ... ]

const encoded = await codec.encode(bytes);
console.log(encoded);
// Uint8Array(3744) [2, 1, 33, 4, 128, 26, 6, 0, 0, 0, 4, 0, ... ]

const decoded = await codec.decode(encoded);
console.log(new Uint32Array(decoded.buffer));
// Uint32Array(100000) [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,  ... ]
```

### Author's note

This project is an incomplete TypeScript implementation of the buffer compression library
[`numcodecs`](https://github.com/zarr-developers/numcodecs). The following codecs
are currently supported:

- `blosc`
- `gzip`
- `lz4`
- `zlib`
- `zstd`


### 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](https://www.skypack.dev/).

- Node / bundlers
```javascript
// Main entry point (exports all codecs)
import { Zlib } from 'numcodecs';

// Submodule entry point (exports only `zlib`)
import Zlib from 'numcodecs/zlib';
```

- Browser / Deno
```javascript
// Main entry point (exports all codecs)
import { Zlib } from 'https://cdn.skypack.dev/numcodecs';

// Submodule entry point (exports only `zlib`)
import Zlib from 'https://cdn.skypack.dev/numcodecs/zlib';
```

### Development

```bash
$ 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](https://www.docker.com/) with the following commands:

```bash
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](https://github.com/changesets/action) will create
and update a PR that applies changesets and publishes new versions.

---
_Source: https://npm.io/package/numcodecs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
