Marshaling serializer for modern JavaScript primitives + circular objects
Last updated a year ago by hash-bang .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @momsfriendlydevco/marshal 
SYNC missed versions from official npm registry.


A simple marshaling serializer for modern JavaScript primitives.


  • Will attempt to serialize all known JS primitive types (dates, NaN, sets, undefined etc.)
  • Can serialize / deserialize circular structures
  • Simple serialize / deserialize usage
  • Extremely fast - uses its own traversal system rather than a 3rd party NPM library
  • Low dependency count - only Lodash is needed
var marshal = require('@momsfriendlydevco/marshal');

var serializedString = marshal.serialize({... some complex object ...});

var deserializedObject = marshal.deserialize(serializedString);

See the testkit for more complex examples.


marshal.serialize(Object, [Settings])

The object or primitive to transform into a string. Settings are inherited from the main marshal.settings structure or overridden by any settings passed in here.

marshal.deserialize(String, [Settings])

Transform a serialized string back into a native JS object. Settings are inherited from the main marshal.settings structure or overridden by any settings passed in here.


The objects to use when operating.

Option Type Default Description
clone Boolean false Clone the input to the serialize / deserialize functions before operating. Adds overhead but will not mutate the input
circular Boolean true Detect and manage circular references, if you know the input / output object cannot be circular there is a speed bonus to disabling this
symetric Boolean false Encode objects symetrically - i.e. reorder keys so that they can be consistantly hashed
depth Number 0 The maximum depth to traverse into when operating. If zero this is infinite
modules Array All modules Which modules to use when operating (see notes below)
stringify Boolean true Whether to transform the mutated object in marshal.serialize() into a string
destringify Boolean true Assume that input to marshal.deserialize() is a string which needs transforming first


  • Modules can be specified as simple strings (e.g. 'date') which assumes they are built in modules provided with the NPM, if this is a path that path is automatically included. If this is an object it is assumed to be an already compatible module
  • All modules must expose a id, test, serialize and deserialize properties

Current Tags

  • 1.1.0                                ...           latest (a year ago)

4 Versions

  • 1.1.0                                ...           a year ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.0                                ...           2 years ago
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 2
Dependencies (2)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |