snappy
!!! For [email protected]
and below, please go to node-snappy
.
More background about the 6-7 changes, please read this, Thanks @kesla .
π Help me to become a full-time open-source developer by sponsoring me on Github
Fastest Snappy compression library in Node.js, powered by napi-rs and rust-snappy.
For small size data, 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 | |
---|---|---|---|
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 | β | β | β |
FreeBSD x64 | β | β | β |
API
export function compressSync(input: Buffer | string | ArrayBuffer | Uint8Array): Buffer
export function compress(input: Buffer | string | ArrayBuffer | Uint8Array): Promise<Buffer>
export function uncompressSync(compressed: Buffer): Buffer
export function uncompress(compressed: Buffer): Promise<Buffer>
Performance
Hardware
Model Name: MacBook Pro
Model Identifier: MacBookPro15,1
Processor Name: 6-Core Intel Core i7
Processor Speed: 2.6 GHz
Number of Processors: 1
Total Number of Cores: 6
L2 Cache (per Core): 256 KB
L3 Cache: 12 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB
Result
Running "Compress" suite...
Progress: 25%
snappy:
1 426 ops/s, Β±2.26%
gzip:
152 ops/s, Β±1.54%
deflate:
155 ops/s, Β±2.14%
brotli:
3 ops/s, Β±3.43% | slowest, 99.79% slower
Finished 4 cases!
Fastest: snappy
Slowest: brotli
Running "Decompress" suite...
Progress: 25%
snappy:
2 771 ops/s, Β±1.13%
gzip:
854 ops/s, Β±6.99%
deflate:
877 ops/s, Β±3.19%
brotli:
638 ops/s, Β±2.31% | slowest, 76.98% slower
Finished 4 cases!
Fastest: snappy
Slowest: brotli