|
2 | 2 |
|
3 | 3 | var pumpify = require('pumpify') |
4 | 4 | var through = require('through2') |
5 | | -var lpStream = require('length-prefixed-stream') |
6 | 5 | var msgpack = require('msgpack-lite') |
7 | 6 | var snappy = require('snappyjs') |
8 | 7 |
|
9 | 8 | module.exports.createEncodeStream = function SnappyMsgpackEncodeStream (stream) { |
10 | | - var msgEncode = through.obj(function (data, enc, next) { |
11 | | - next(null, msgpack.encode(data)) |
12 | | - }) |
| 9 | + var msgEncode = msgpack.createEncodeStream() |
13 | 10 |
|
14 | 11 | var snappyCompress = through.obj(function (data, enc, next) { |
15 | 12 | next(null, snappy.compress(data)) |
16 | 13 | }) |
17 | 14 |
|
18 | | - return pumpify.obj(msgEncode, snappyCompress, lpStream.encode()) |
| 15 | + return pumpify.obj(msgEncode, snappyCompress) |
19 | 16 | } |
20 | 17 |
|
21 | 18 | module.exports.createDecodeStream = function SnappyMsgpackDecodeStream (stream) { |
22 | | - var msgDecode = through.obj(function (data, enc, next) { |
23 | | - next(null, msgpack.decode(data)) |
24 | | - }) |
| 19 | + var msgDecode = msgpack.createDecodeStream() |
25 | 20 |
|
26 | 21 | var snappyUncompress = through.obj(function (data, enc, next) { |
27 | 22 | next(null, snappy.uncompress(data)) |
28 | 23 | }) |
29 | 24 |
|
30 | | - return pumpify.obj(lpStream.decode(), snappyUncompress, msgDecode) |
| 25 | + return pumpify.obj(snappyUncompress, msgDecode) |
31 | 26 | } |
0 commit comments