npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@momsfriendlydevco/marshal

v2.0.0

Published

Marshaling serializer for modern JavaScript primitives + circular objects

Downloads

44

Readme

@momsfriendlydevco/marshal

A simple marshaling serializer for modern JavaScript primitives.

Features:

  • 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.

API

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.

marshal.settings

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 |

NOTES:

  • 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