Skip to content

Commit

Permalink
fix: use serialize method
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 6, 2019
1 parent 70cd118 commit 099e43f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ const createCompress = ({
} = {}) => {
if (!enable) return noop

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

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

return {
compress: async data => {
if (data === undefined) return data
let serializedData = JSON.stringify(data)
let serializedData = serialize(data)
if (!hasNativeAPI) serializedData = Buffer.from(serializedData)
return compress(serializedData)
},
Expand Down

0 comments on commit 099e43f

Please sign in to comment.