MSGP
Byte message protocol and streaming parser for Node.js.
https://github.com/iorust/msgp-rust
Rust version:Protocol
Bench
1000000 simple messages, amp vs msgp vs resp
- Mspg: 23437.50 kb 661813.37 ops
- resp: 29296.88 kb 646412.41 ops
- Amp: 27343.75 kb 222419.93 ops
API
const Msgp =
Class Msgp
new Msgp()
Create a writeable like stream parser.
const msgp = msgpsomeSocketStream
msgp.write(buffer)
msgp
Event: 'data'
msgp
Event: 'error'
Event: 'drain'
Event: 'null'
Event: 'finish'
Class Method: Msgp.encode(string)
Class Method: Msgp.encode(buffer)
Encode string or buffer to buffer packet.
Msgp// result: <Buffer 0f 7b 22 6e 61 6d 65 22 3a 22 6d 73 67 70 22 7d>
Class Method: Msgp.decode(buffer)
Decode buffer packet to message buffer.
let buf = 0x0f 0x7b 0x22 0x6e 0x61 0x6d 0x65 0x22 0x3a 0x22 0x6d 0x73 0x67 0x70 0x22 0x7dJSON// result: {name: 'msgp'}
License
MIT © zensh