Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Brooooooklyn/snappy
Fastest Snappy compression library in Node.js
https://github.com/Brooooooklyn/snappy
compression napi napi-rs node-api rust snappy
Last synced: about 2 months ago
JSON representation
Fastest Snappy compression library in Node.js
- Host: GitHub
- URL: https://github.com/Brooooooklyn/snappy
- Owner: Brooooooklyn
- License: mit
- Created: 2021-06-09T14:28:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T02:00:03.000Z (about 2 months ago)
- Last Synced: 2024-10-28T14:27:53.408Z (about 2 months ago)
- Topics: compression, napi, napi-rs, node-api, rust, snappy
- Language: Rust
- Homepage:
- Size: 12.3 MB
- Stars: 164
- Watchers: 4
- Forks: 9
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# `snappy`
![https://github.com/Brooooooklyn/snappy/actions](https://github.com/Brooooooklyn/snappy/workflows/CI/badge.svg)
![](https://img.shields.io/npm/dm/snappy.svg?sanitize=true)
[![Install size](https://packagephobia.com/badge?p=snappy)](https://packagephobia.com/result?p=snappy)**!!! For `[email protected]` and below, please go to [`node-snappy`](https://github.com/kesla/node-snappy).**
More background about the **6-7** changes, please read [this](https://github.com/Brooooooklyn/snappy/issues/16), Thanks [@kesla](https://github.com/kesla) .
> 🚀 Help me to become a full-time open-source developer by [sponsoring me on Github](https://github.com/sponsors/Brooooooklyn)
Fastest Snappy compression library in Node.js, powered by [napi-rs](https://napi.rs) and [rust-snappy](https://github.com/BurntSushi/rust-snappy).
> For small size data, [snappyjs](https://github.com/zhipeng-jia/snappyjs) is faster, and it support browser. But it doesn't have async API, which is important for Node.js program.
## Install this package
```
yarn add snappy
```## Support matrix
| | node12 | node14 | node16 | node18 |
| ---------------- | ------ | ------ | ------ | ------ |
| Windows x64 | ✓ | ✓ | ✓ | ✓ |
| Windows x32 | ✓ | ✓ | ✓ | ✓ |
| Windows arm64 | ✓ | ✓ | ✓ | ✓ |
| macOS x64 | ✓ | ✓ | ✓ | ✓ |
| macOS arm64 | ✓ | ✓ | ✓ | ✓ |
| Linux x64 gnu | ✓ | ✓ | ✓ | ✓ |
| Linux x64 musl | ✓ | ✓ | ✓ | ✓ |
| Linux arm gnu | ✓ | ✓ | ✓ | ✓ |
| Linux arm64 gnu | ✓ | ✓ | ✓ | ✓ |
| Linux arm64 musl | ✓ | ✓ | ✓ | ✓ |
| Android arm64 | ✓ | ✓ | ✓ | ✓ |
| Android armv7 | ✓ | ✓ | ✓ | ✓ |
| FreeBSD x64 | ✓ | ✓ | ✓ | ✓ |## API
```ts
export function compressSync(input: Buffer | string | ArrayBuffer | Uint8Array): Buffer
export function compress(input: Buffer | string | ArrayBuffer | Uint8Array): Promise
export function uncompressSync(compressed: Buffer): Buffer
export function uncompress(compressed: Buffer): Promise
```## Performance
### Hardware
```
OS: Windows 11 x86_64
Host: Micro-Star International Co., Ltd. MS-7C35
Kernel: 10.0.22000
Terminal: Windows Terminal
CPU: AMD Ryzen 9 5950X (32) @ 3.400GHz
Memory: 32688MiB
```### Result
```
Running "Compress" suite...
Progress: 100%snappy:
4 220 ops/s, ±0.66% | fastestsnappy-v6:
2 018 ops/s, ±0.84% | 52.18% slowergzip:
233 ops/s, ±0.52% | slowest, 94.48% slowerdeflate:
235 ops/s, ±0.45% | 94.43% slowerbrotli:
7 ops/s, ±0.51% | slowest, 99.85% slowerFinished 4 cases!
Fastest: snappy
Slowest: brotliRunning "Decompress" suite...
Progress: 100%snappy:
8 528 ops/s, ±1.03% | fastestsnappy-v6:
6 357 ops/s, ±1.76% | 25.46% slowergzip:
1 406 ops/s, ±1.80% | slowest, 83.51% slowerdeflate:
1 435 ops/s, ±1.88% | 83.17% slowerbrotli:
1 208 ops/s, ±1.50% | slowest, 86.99% slowerFinished 4 cases!
Fastest: snappy
Slowest: brotli
```