A fast Node.js implementation of the latest MessagePack spec.
- This implementation is not backwards compatible with those that use the older spec. It is recommended that this library is only used in isolated systems.
undefinedis encoded asfixext 1 [0, 0], i.e.<Buffer d4 00 00>Dateobjects are encoded asfixext 8 [0, ms], e.g.new Date('2000-06-13T00:00:00.000Z')=><Buffer d7 00 00 00 00 df b7 62 9c 00>
npm install notepack
var notepack = require('notepack');
var encoded = notepack.encode({ foo: 'bar'}); // <Buffer 81 a3 66 6f 6f a3 62 61 72>
var decoded = notepack.decode(encoded); // { foo: 'bar' }Performance is currently comparable to msgpack-node (which presumably needs optimizing and suffers from JS-native overhead) and is significantly faster than other implementations. Several micro-optimizations are used to improve the performance of short string and Buffer operations.
The ./benchmarks/run output on my machine is:
Encoding (this will take a while):
+----------------------------+-----------------+-----------------+----------------+---------------+
| β tiny β small β medium β large |
+----------------------------+-----------------+-----------------+----------------+---------------+
| notepack β 758,340 ops/sec β 172,415 ops/sec β 18,614 ops/sec β 262 ops/sec |
+----------------------------+-----------------+-----------------+----------------+---------------+
| msgpack-js β 100,768 ops/sec β 27,229 ops/sec β 3,044 ops/sec β 93.47 ops/sec |
+----------------------------+-----------------+-----------------+----------------+---------------+
| msgpack-node β 206,825 ops/sec β 107,619 ops/sec β 20,362 ops/sec β 284 ops/sec |
+----------------------------+-----------------+-----------------+----------------+---------------+
| JSON.stringify (to Buffer) β 528,632 ops/sec β 154,229 ops/sec β 12,023 ops/sec β 7.82 ops/sec |
+----------------------------+-----------------+-----------------+----------------+---------------+
Decoding (this will take a while):
+--------------------------+-------------------+-----------------+----------------+---------------+
| β tiny β small β medium β large |
+--------------------------+-------------------+-----------------+----------------+---------------+
| notepack β 756,003 ops/sec β 163,630 ops/sec β 15,771 ops/sec β 144 ops/sec |
+--------------------------+-------------------+-----------------+----------------+---------------+
| msgpack-js β 425,628 ops/sec β 101,821 ops/sec β 10,117 ops/sec β 123 ops/sec |
+--------------------------+-------------------+-----------------+----------------+---------------+
| msgpack-node β 717,093 ops/sec β 165,781 ops/sec β 23,506 ops/sec β 155 ops/sec |
+--------------------------+-------------------+-----------------+----------------+---------------+
| JSON.parse (from Buffer) β 1,441,579 ops/sec β 396,923 ops/sec β 28,594 ops/sec β 33.94 ops/sec |
+--------------------------+-------------------+-----------------+----------------+---------------+
* Note that JSON is provided as an indicative comparison only
MIT