diff --git a/index.js b/index.js index 1e6916e..74a29fb 100644 --- a/index.js +++ b/index.js @@ -3,29 +3,39 @@ var snappy = require('snappyjs') var msgpack = require('msgpack-lite') var lpStream = require('length-prefixed-stream') -var stream = require('stream') -var pumpify = require('pumpify') +var Transform = require('readable-stream/transform') -var snappyCompressStream = new stream.Transform({ +var msgpackEncodeStream = new Transform({ + objectMode: true, + transform: function (chunk, encoding, next) { + next(null, msgpack.encode(chunk)) + } +}) + +var msgpackDecodeStream = new Transform({ + objectMode: true, + transform: function (chunk, encoding, callback) { + callback(null, msgpack.decode(chunk)) + } +}) + +var snappyCompressStream = new Transform({ transform: function (chunk, encoding, next) { next(null, snappy.compress(chunk)) } }) -var snappyUncompressStream = new stream.Transform({ +var snappyUncompressStream = new Transform({ transform: function (chunk, encoding, callback) { callback(null, snappy.uncompress(chunk)) } }) exports.createEncodeStream = function SnappyMsgpackEncodeStream () { - return pumpify.obj( - pumpify.obj(msgpack.createEncodeStream(), snappyCompressStream), - lpStream.encode()) + msgpackEncodeStream.pipe(snappyCompressStream).pipe(lpStream.encode()) + return msgpackEncodeStream } exports.createDecodeStream = function SnappyMsgpackDecodeStream () { - return pumpify.obj( - pumpify.obj(lpStream.decode(), snappyUncompressStream), - msgpack.createDecodeStream()) + return lpStream.decode().pipe(snappyUncompressStream).pipe(msgpackDecodeStream) } diff --git a/package.json b/package.json index c64796f..f01289f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dependencies": { "length-prefixed-stream": "^1.5.1", "msgpack-lite": "^0.1.26", - "pumpify": "^1.3.5", + "readable-stream": "^2.2.2", "snappyjs": "^0.5.0" }, "keywords": [ @@ -22,7 +22,7 @@ "author": "Klaus Trainer ", "license": "MIT", "devDependencies": { - "semantic-release": "^6.3.6", + "semantic-release": "^6.3.2", "standard": "^8.0.0", "tape": "^4.6.0" },