compress-brotli
Advanced tools
Comparing version 1.0.8 to 1.1.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.1.0](https://github.com/Kikobeats/compress-brotli/compare/v1.0.8...v1.1.0) (2019-11-01) | ||
### Features | ||
* add buffer stringify support ([67757a8](https://github.com/Kikobeats/compress-brotli/commit/67757a8e6964aa89aff28bb14d5c474d28d00f86)) | ||
### [1.0.8](https://github.com/Kikobeats/compress-brotli/compare/v1.0.7...v1.0.8) (2019-09-21) | ||
@@ -7,0 +14,0 @@ |
20
index.js
@@ -5,22 +5,16 @@ 'use strict' | ||
const zlib = require('zlib') | ||
const JSONB = require('buffer-json') | ||
const hasNativeAPI = Boolean(zlib.brotliCompress) | ||
const identity = val => val | ||
const defaultSerialize = val => Buffer.from(JSON.stringify(val)) | ||
const defaultDeserialize = JSON.parse | ||
const noop = { | ||
deserialize: defaultDeserialize, | ||
serialize: defaultSerialize, | ||
decompress: data => data, | ||
compress: data => data | ||
} | ||
const createCompress = ({ | ||
enable = true, | ||
serialize = defaultSerialize, | ||
deserialize = defaultDeserialize, | ||
serialize = JSONB.stringify, | ||
deserialize = JSONB.parse, | ||
iltorb = () => require('iltorb') | ||
} = {}) => { | ||
if (!enable) return noop | ||
if (!enable) { | ||
return { serialize, deserialize, decompress: identity, compress: identity } | ||
} | ||
@@ -27,0 +21,0 @@ const compress = hasNativeAPI |
@@ -5,7 +5,7 @@ { | ||
"homepage": "https://nicedoc.io/Kikobeats/compress-brotli", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
"author": { | ||
"email": "josefrancisco.verdu@gmail.com", | ||
"name": "Kiko Beats", | ||
"email": "josefrancisco.verdu@gmail.com", | ||
"url": "https://kikobeats.com" | ||
@@ -33,2 +33,5 @@ }, | ||
], | ||
"dependencies": { | ||
"buffer-json": "~2.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -57,16 +60,18 @@ "@commitlint/cli": "latest", | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf node_modules", | ||
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "standard-markdown README.md && standard", | ||
"postrelease": "npm run release:tags && npm run release:github && ci-publish", | ||
"precommit": "lint-staged", | ||
"prerelease": "npm run update:check", | ||
"prerelease": "npm run update:check && npm run contributors", | ||
"pretest": "npm run lint", | ||
"pretty": "prettier-standard index.js {core,test,bin,scripts}/**/*.js --single-quote --print-width 100", | ||
"release": "git-authors-cli && git add package.json && standard-version -a", | ||
"release": "standard-version -a", | ||
"release:github": "conventional-github-releaser -p angular", | ||
"release:tags": "git push --follow-tags origin HEAD:master", | ||
"test": "nyc ava", | ||
"update": "ncu -a", | ||
"update": "ncu -u", | ||
"update:check": "ncu -- --error-level 2" | ||
@@ -87,17 +92,15 @@ }, | ||
"lint-staged": { | ||
"linters": { | ||
"package.json": [ | ||
"finepack", | ||
"git add" | ||
], | ||
"*.js": [ | ||
"prettier-standard", | ||
"git add" | ||
], | ||
"*.md": [ | ||
"standard-markdown", | ||
"git add" | ||
] | ||
} | ||
"package.json": [ | ||
"finepack", | ||
"git add" | ||
], | ||
"*.js": [ | ||
"prettier-standard", | ||
"git add" | ||
], | ||
"*.md": [ | ||
"standard-markdown", | ||
"git add" | ||
] | ||
} | ||
} |
@@ -55,3 +55,3 @@ # compress-brotli | ||
Type: `function`<br> | ||
Default: `JSON.stringify` | ||
Default: `JSONB.stringify` | ||
@@ -63,3 +63,3 @@ It determines the serialize method to use before compress the data. | ||
Type: `function`<br> | ||
Default: `JSON.parse` | ||
Default: `JSONB.parse` | ||
@@ -66,0 +66,0 @@ It determines the deserialize method to use after decompress the data. |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
0
9219
1
5
36
+ Addedbuffer-json@~2.0.0
+ Addedbuffer-json@2.0.0(transitive)