Skip to content
yisiblPublic

About

Google brotli binding to Node.js via Rust and napi-rs

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

brotli-js

GitHub CI Status

Google brotli binding to Node.js via Rust and napi-rs

This library is mainly used to test the performance of napi-rs v2. For actual development, please use the zlib.brotliCompress() method that comes with Node.js.

  • Cross-platform support, including Apple M1.
  • No need for node-gyp and postinstall, the .node file has been compiled for you.

Installation

npm i @brotli/brotli-js
cnpm i @brotli/brotli-js
pnpm i @brotli/brotli-js

Support matrix

node12 node14 node16 npm
Windows x64 ✓ ✓ ✓ npm version
Windows x32 ✓ ✓ ✓ npm version
Windows arm64 ✓ ✓ ✓ npm version
macOS x64 ✓ ✓ ✓ npm version
macOS arm64(M1) ✓ ✓ ✓ npm version
Linux x64 gnu ✓ ✓ ✓ npm version
Linux x64 musl ✓ ✓ ✓ npm version
Linux arm gnu ✓ ✓ ✓ npm version
Linux arm64 gnu ✓ ✓ ✓ npm version
Linux arm64 musl ✓ ✓ ✓ npm version
Android arm64 ✓ ✓ ✓ npm version

benchmarks

npm run bench

Running "1024 Bytes" suite...
  zlib(Native):
    262 ops/s, ±6.68%   | fastest

  iltorb(C++):
    248 ops/s, ±3.40%   | 5.34% slower

  brotli-js(Rust):
    115 ops/s, ±1.74%   | slowest, 56.11% slower

Build

You can set the name of the generated .node file in napi.name of package.json.

After npm run build command, you can see brotlijs.[darwin|win32|linux].node file in project root. This is the native addon built from lib.rs.

Develop requirements

  • Install latest Rust
  • Install Node.js@10+ which fully supported Node-API
  • Install yarn@1.x

Test in local

  • yarn
  • yarn build
  • yarn test

And you will see:

$ ava --verbose

  ✔ sync function from native code
  ✔ sleep function from native code (201ms)
  ─

  2 tests passed
✨  Done in 1.12s.

Release package

We use GitHub actions to automatically publish npm packages.

# 1.0.0 => 1.0.1
npm version patch

# or 1.0.0 => 1.1.0
npm version minor

git push --follow-tags

License

MIT

About

Google brotli binding to Node.js via Rust and napi-rs

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages