Skip to content

corinis/msgpack-javascript

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MessagePack with key extension

Space-efficient binary serialization format.

This includes an extension to remove xtra space for duplicate keys:

format namefirst byte (in binary)first byte (in hex)
fixext 1110101000xd4
fixext 2110101010xd5

where:

Y: 1-512 unit id of a map space
key: the string to save in that map space
+--------+--------+========+
|  0xd4  |YYYYYYYY|  key  |
+--------+--------+========+

Z: lookup the previously assigned key
+--------+--------+
|  0xd5  |ZZZZZZZZ|
+--------+--------+

this allows reused keys (i.e. for object serialization) to use up much less space.

I.e. if you have a list of objects like {id:1,name:"test"} you will save 4 bytes per iteration (one from id, and 3 from name)

Quick start

// Got ArrayBuffer object
var packed = msgpack.pack( { the: { very: [ "long", true, "data" ], "structure" },
                             depth: "is", such: [ NaN, Inifinity ],
                             wow: new ArrayBuffer(100), is: 100 } );

// Got the original "such much" data structure
var data = msgpack.unpack(packed);

Options

  • msgpack.MAX_DEPTH = 512 - adjust maximum allowable data depth

About

MessagePack serializer implementation for JavaScript / msgpack.org[JavaScript]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 59.6%
  • JavaScript 40.4%