Socket
Socket
Sign inDemoInstall

snappy

Package Overview
Dependencies
13
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.5 to 7.1.0

29

index.d.ts

@@ -1,10 +0,19 @@

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 uncompressSync(compressed: Buffer, opt: { asBuffer: true }): Buffer
export function uncompressSync(compressed: Buffer, opt: { asBuffer: false }): string
export function uncompressSync(compressed: Buffer, opt?: { asBuffer: boolean }): string | Buffer
export function uncompress(compressed: Buffer): Promise<Buffer>
export function uncompress(compressed: Buffer, opt: { asBuffer: true }): Promise<Buffer>
export function uncompress(compressed: Buffer, opt: { asBuffer: false }): Promise<string>
export function uncompress(compressed: Buffer, opt?: { asBuffer: boolean }): Promise<string | Buffer>
/* eslint-disable */
export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}
export interface Options {
asBuffer?: boolean | undefined | null
}
export function compressSync(input: Buffer | string): Buffer
export function compress(input: string | Buffer, signal?: AbortSignal | undefined | null): Promise<Buffer>
export function uncompressSync(input: string | Buffer, asBuffer?: Options | undefined | null): string | Buffer
export function uncompress(
input: string | Buffer,
options?: Options | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string | Buffer>

@@ -1,24 +0,200 @@

const { loadBinding } = require('@node-rs/helper')
const { existsSync, readFileSync } = require('fs')
const { join } = require('path')
const {
compressSync: _compressSync,
compress: _compress,
uncompress: _uncompress,
uncompressSync: _uncompressSync,
} = loadBinding(__dirname, 'snappy', '@napi-rs/snappy')
const { platform, arch } = process
module.exports.compress = function compress(input) {
return _compress(Buffer.isBuffer(input) ? input : Buffer.from(input))
}
let nativeBinding = null
let localFileExisted = false
let isMusl = false
let loadError = null
module.exports.compressSync = function compressSync(input) {
return _compressSync(Buffer.isBuffer(input) ? input : Buffer.from(input))
switch (platform) {
case 'android':
if (arch !== 'arm64') {
throw new Error(`Unsupported architecture on Android ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'snappy.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.android-arm64.node')
} else {
nativeBinding = require('snappy-android-arm64')
}
} catch (e) {
loadError = e
}
break
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'snappy.win32-x64-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.win32-x64-msvc.node')
} else {
nativeBinding = require('snappy-win32-x64-msvc')
}
} catch (e) {
loadError = e
}
break
case 'ia32':
localFileExisted = existsSync(join(__dirname, 'snappy.win32-ia32-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.win32-ia32-msvc.node')
} else {
nativeBinding = require('snappy-win32-ia32-msvc')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'snappy.win32-arm64-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.win32-arm64-msvc.node')
} else {
nativeBinding = require('snappy-win32-arm64-msvc')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`)
}
break
case 'darwin':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'snappy.darwin-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.darwin-x64.node')
} else {
nativeBinding = require('snappy-darwin-x64')
}
} catch (e) {
loadError = e
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'snappy.darwin-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.darwin-arm64.node')
} else {
nativeBinding = require('snappy-darwin-arm64')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`)
}
break
case 'freebsd':
if (arch !== 'x64') {
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
}
localFileExisted = existsSync(join(__dirname, 'snappy.freebsd-x64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.freebsd-x64.node')
} else {
nativeBinding = require('snappy-freebsd-x64')
}
} catch (e) {
loadError = e
}
break
case 'linux':
switch (arch) {
case 'x64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-x64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-x64-musl.node')
} else {
nativeBinding = require('snappy-linux-x64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-x64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-x64-gnu.node')
} else {
nativeBinding = require('snappy-linux-x64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm64':
isMusl = readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
if (isMusl) {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-arm64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-arm64-musl.node')
} else {
nativeBinding = require('snappy-linux-arm64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-arm64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-arm64-gnu.node')
} else {
nativeBinding = require('snappy-linux-arm64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'snappy.linux-arm-gnueabihf.node'))
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('snappy-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
break
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`)
}
break
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
module.exports.uncompress = function uncompress(input, opt = { asBuffer: true }) {
return _uncompress(Buffer.isBuffer(input) ? input : Buffer.from(input), Boolean(opt.asBuffer))
if (!nativeBinding) {
if (loadError) {
throw loadError
}
throw new Error(`Failed to load native binding`)
}
module.exports.uncompressSync = function uncompressSync(input, opt = { asBuffer: true }) {
return _uncompressSync(Buffer.isBuffer(input) ? input : Buffer.from(input), Boolean(opt.asBuffer))
}
const { compressSync, compress, uncompressSync, uncompress } = nativeBinding
module.exports.compressSync = compressSync
module.exports.compress = compress
module.exports.uncompressSync = uncompressSync
module.exports.uncompress = uncompress
{
"name": "snappy",
"version": "7.0.5",
"version": "7.1.0",
"description": "Fastest Snappy compression library in Node.js",

@@ -36,2 +36,3 @@ "main": "index.js",

"aarch64-linux-android",
"arm-linux-androideabi",
"x86_64-unknown-freebsd",

@@ -53,54 +54,42 @@ "aarch64-unknown-linux-musl",

"bench": "node -r @swc-node/register benchmark/bench.ts",
"build": "napi build --platform --release",
"build": "napi build --platform --release --pipe \"prettier --loglevel silent -w\"",
"build:debug": "napi build --platform",
"format": "run-p format:md format:json format:yaml format:source format:rs",
"format:md": "prettier --parser markdown --write \"./**/*.md\"",
"format:json": "prettier --parser json --write \"./**/*.json\"",
"format": "run-p format:source format:rs",
"format:rs": "cargo fmt",
"format:source": "prettier --config ./package.json --write \"./**/*.{js,ts}\"",
"format:yaml": "prettier --parser yaml --write \"./**/*.{yml,yaml}\"",
"format:source": "prettier --config ./package.json --write .",
"lint": "eslint -c ./.eslintrc.yml .",
"prepublishOnly": "napi prepublish -t npm && node ./rename-optional-deps.js",
"test": "ava",
"test:mem": "node ./memory-leak-detect.js",
"test:mem": "node ./memory-leak-detect.mjs",
"version": "napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
},
"devDependencies": {
"@napi-rs/cli": "^1.1.0",
"@swc-node/register": "^1.3.3",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@napi-rs/cli": "^2.1.0",
"@swc-node/register": "^1.4.2",
"@types/node": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"ava": "^3.15.0",
"benny": "^3.6.15",
"chalk": "^4.1.2",
"benny": "^3.7.1",
"chalk": "^5.0.0",
"conventional-changelog-cli": "^2.1.1",
"eslint": "^7.32.0",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-sonarjs": "^0.10.0",
"husky": "^7.0.1",
"lint-staged": "^11.1.1",
"husky": "^7.0.4",
"lint-staged": "^12.1.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"prettier": "^2.5.1",
"pretty-bytes": "^5.6.0",
"table": "^6.7.1",
"typescript": "^4.3.5"
"table": "^6.7.5",
"typescript": "^4.5.4"
},
"dependencies": {
"@node-rs/helper": "^1.2.1"
},
"dependencies": {},
"lint-staged": {
"*.@(js|ts|tsx)": [
"prettier --write",
"eslint -c .eslintrc.yml --fix"
],
"*.@(yml|yaml)": [
"prettier --parser yaml --write"
],
"*.md": [
"prettier --parser markdown --write"
],
"*.json": [
"prettier --parser json --write"
"*.@(js|ts|tsx|yml|yaml|md|json)": [
"prettier --write"
]

@@ -124,4 +113,3 @@ },

"singleQuote": true,
"arrowParens": "always",
"parser": "typescript"
"arrowParens": "always"
},

@@ -133,15 +121,16 @@ "funding": {

"optionalDependencies": {
"@napi-rs/snappy-win32-x64-msvc": "7.0.5",
"@napi-rs/snappy-darwin-x64": "7.0.5",
"@napi-rs/snappy-linux-x64-gnu": "7.0.5",
"@napi-rs/snappy-linux-x64-musl": "7.0.5",
"@napi-rs/snappy-linux-arm64-gnu": "7.0.5",
"@napi-rs/snappy-win32-ia32-msvc": "7.0.5",
"@napi-rs/snappy-linux-arm-gnueabihf": "7.0.5",
"@napi-rs/snappy-darwin-arm64": "7.0.5",
"@napi-rs/snappy-android-arm64": "7.0.5",
"@napi-rs/snappy-freebsd-x64": "7.0.5",
"@napi-rs/snappy-linux-arm64-musl": "7.0.5",
"@napi-rs/snappy-win32-arm64-msvc": "7.0.5"
"@napi-rs/snappy-win32-x64-msvc": "7.1.0",
"@napi-rs/snappy-darwin-x64": "7.1.0",
"@napi-rs/snappy-linux-x64-gnu": "7.1.0",
"@napi-rs/snappy-linux-x64-musl": "7.1.0",
"@napi-rs/snappy-linux-arm64-gnu": "7.1.0",
"@napi-rs/snappy-win32-ia32-msvc": "7.1.0",
"@napi-rs/snappy-linux-arm-gnueabihf": "7.1.0",
"@napi-rs/snappy-darwin-arm64": "7.1.0",
"@napi-rs/snappy-android-arm64": "7.1.0",
"@napi-rs/snappy-android-arm-eabi": "7.1.0",
"@napi-rs/snappy-freebsd-x64": "7.1.0",
"@napi-rs/snappy-linux-arm64-musl": "7.1.0",
"@napi-rs/snappy-win32-arm64-msvc": "7.1.0"
}
}

@@ -25,16 +25,17 @@ # `snappy`

| | 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 | ✓ | ✓ | ✓ |
| | node12 | node14 | node16 | node17 |
| ---------------- | ------ | ------ | ------ | ------ |
| 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 | ✓ | ✓ | ✓ | ✓ |

@@ -55,12 +56,8 @@ ## API

```
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
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
```

@@ -72,15 +69,15 @@

Running "Compress" suite...
Progress: 25%
Progress: 100%
snappy:
1 426 ops/s, ±2.26%
4 690 ops/s, ±0.66% | fastest
gzip:
152 ops/s, ±1.54%
259 ops/s, ±0.85% | 94.48% slower
deflate:
155 ops/s, ±2.14%
262 ops/s, ±0.59% | 94.41% slower
brotli:
3 ops/s, ±3.43% | slowest, 99.79% slower
7 ops/s, ±0.51% | slowest, 99.85% slower

@@ -92,15 +89,15 @@ Finished 4 cases!

Running "Decompress" suite...
Progress: 25%
Progress: 100%
snappy:
2 771 ops/s, ±1.13%
9 285 ops/s, ±6.18% | fastest
gzip:
854 ops/s, ±6.99%
1 511 ops/s, ±1.96% | 83.73% slower
deflate:
877 ops/s, ±3.19%
1 763 ops/s, ±1.36% | 81.01% slower
brotli:
638 ops/s, ±2.31% | slowest, 76.98% slower
1 208 ops/s, ±1.50% | slowest, 86.99% slower

@@ -107,0 +104,0 @@ Finished 4 cases!

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc