Streams of framed Snappy-compressed MessagePack messages.
var snappyStream = require('snappy-msgpack-stream');
var encode = snappyStream.createEncodeStream();
var decode = snappyStream.createDecodeStream();
encode.pipe(decode);
decode.on('data', console.log);
encode.write('HELLO');
encode.write({object: true});
encode.write(true);
encode.write({foo: true, bar: 42, baz: null, pow: "wow"});
// encode.write(anyMessagePackSerializableObject);
Please note that MessagePack does not support many JavaScript types, like e.g. Infinity
or NaN
. However, we use msgpack-lite, which implements a slightly extended MessagePack protocol, and allows encoding and decoding Infinity
and NaN
, as well as Buffer
instances.