Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yisibl/brotli-js
Google brotli binding to Node.js via Rust and napi-rs
https://github.com/yisibl/brotli-js
Last synced: 17 days ago
JSON representation
Google brotli binding to Node.js via Rust and napi-rs
- Host: GitHub
- URL: https://github.com/yisibl/brotli-js
- Owner: yisibl
- License: mit
- Created: 2021-10-17T15:02:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-17T11:17:21.000Z (almost 3 years ago)
- Last Synced: 2024-10-09T08:09:05.323Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 28.3 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# brotli-js
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](https://www.apple.com/newsroom/2020/11/apple-unleashes-m1/).
- No need for node-gyp and postinstall, the `.node` file has been compiled for you.## Installation
```shell
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](https://img.shields.io/npm/v/@brotli/brotli-js-win32-x64-msvc.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-win32-x64-msvc) |
| |
| Windows x32 | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-win32-ia32-msvc.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-win32-ia32-msvc) |
| |
| Windows arm64 | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-win32-arm64-msvc.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-win32-arm64-msvc) |
| |
| macOS x64 | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-darwin-x64.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-darwin-x64) |
| |
| macOS arm64(M1) | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-darwin-arm64.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-darwin-arm64) |
| |
| Linux x64 gnu | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-linux-x64-gnu.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-linux-x64-gnu) |
| |
| Linux x64 musl | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-linux-x64-musl.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-linux-x64-musl) |
| |
| Linux arm gnu | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-linux-arm-gnueabihf.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-linux-arm-gnueabihf) |
| |
| Linux arm64 gnu | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-linux-arm64-gnu.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-linux-arm64-gnu) |
| |
| Linux arm64 musl | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-linux-arm64-musl.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-linux-arm64-musl) |
| |
| Android arm64 | ✓ | ✓ | ✓ | [![npm version](https://img.shields.io/npm/v/@brotli/brotli-js-android-arm64.svg?sanitize=true)](https://www.npmjs.com/package/@brotli/brotli-js-android-arm64) |
| |## benchmarks
```shell
npm run benchRunning "1024 Bytes" suite...
zlib(Native):
262 ops/s, ±6.68% | fastestiltorb(C++):
248 ops/s, ±3.40% | 5.34% slowerbrotli-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](./src/lib.rs).
## Develop requirements
- Install latest `Rust`
- Install `Node.js@10+` which fully supported `Node-API`
- Install `[email protected]`## Test in local
- yarn
- yarn build
- yarn testAnd you will see:
```bash
$ 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 minorgit push --follow-tags
```## License
MIT