node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


JS Binary Data

Binary data serializer and unserializer for Node.js.


Serialize and unserialize any Javascript data.


  • All Javascript basic types: undefined, null, boolean, number, string, array and object
  • ES6 Set and Map
  • Relational data & circular references: no object duplication, the output structure is the same than the input was
  • Prototype chain is supported (require the 'prototypeChain' serializer option)
  • Instance of non-trivial object are supported, if a map of names to prototype/constructor is provided (require the 'classMap' option to be set to a common object/map on both the serializer and unserializer)

Serializing to a file example

var stream = fs.createWriteStream( 'path/to/my/file.jsdat' ) ;
await jsbindat.serialize( stream , data ) ;

... or just:

await jsbindat.writeFile( 'path/to/my/file.jsdat' , data ) ;

Unserializing from a file example

var stream = fs.createReadStream( 'path/to/my/file.jsdat' ) ;
var data = await jsbindat.unserialize( stream ) ;
stream.close() ;
// Do something with the data

... or just:

var data = jsbindat.readFile( 'path/to/my/file.jsdat' ) ;

Non-trivial object

TODO: documentation