Blame view
node_modules/msgpack-stream/readme.markdown
1.38 KB
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#MsgPackStream Streams of framed [msgpack](http://msgpack.org) messages. [](https://ci.testling.com/dominictarr/msgpack-stream) ## WARNING this module is *not recommended* parsing `msgpack` in js is much slower than spliting json into lines and parsing with `JSON.parse`, which is heavily optimised in all good js implementations. instead use: [es.parse](https://github.com/dominictarr/event-stream#parse) and [es.stringify](https://github.com/dominictarr/event-stream#stringify) If you really want to use `msgpack` you should fix this issue: [pgreiss/node-msgpack#16](https://github.com/pgriess/node-msgpack/issues/16) ## usage ``` js var mps = require('msgpack-stream') var encode = mps.createEncodeStream() var decode = mps.createDecodeStream() encode.pipe(decode) decode.on('data', console.log) encode.write('HELLO') encode.write({object: true}) encode.write(true) encode.write(AnyValidJsObject) //! ``` ## remarks this is mostly pulled out of [smith](https://github.com/c9/smith) and slightly refactored to fit a stream. ## lies Actually, msgpack does not support much loved js objects such as `Infinity`, or `Nan`. On the other hand, `msgpack-stream` uses [creationix/msgpack-js](https://github.com/creationix/msgpack-js) which implements a slightly extended protocol, so you can pack `Buffer` and `undefined` |