Skip to content

Commit

Permalink
fix: handle buffer case
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 6, 2019
1 parent 4986f2b commit 64b4043
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions index.js
Expand Up @@ -19,7 +19,7 @@ const createCompress = ({

const compress = hasNativeAPI
? promisify(zlib.brotliCompress)
: require('iltorb').decompress
: require('iltorb').compress

const decompress = hasNativeAPI
? promisify(zlib.brotliDecompress)
Expand All @@ -28,7 +28,9 @@ const createCompress = ({
return {
compress: async data => {
if (data === undefined) return data
return compress(serialize(data))
let serializedData = JSON.stringify(data)
if (!hasNativeAPI) serializedData = Buffer.from(serializedData)
return compress(serializedData)
},
decompress: async data => {
if (data === undefined) return data
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -33,20 +33,21 @@
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"ava": "latest",
"ci-publish": "latest",
"conventional-github-releaser": "latest",
"coveralls": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"git-dirty": "latest",
"husky": "latest",
"iltorb": "latest",
"lint-staged": "latest",
"npm-check-updates": "latest",
"nyc": "latest",
"prettier-standard": "latest",
"standard": "latest",
"standard-markdown": "latest",
"standard-version": "latest",
"ci-publish": "latest"
"standard-version": "latest"
},
"engines": {
"node": ">= 8"
Expand Down

0 comments on commit 64b4043

Please sign in to comment.