faster-stable-stringify
Faster deterministic JSON.stringify() without bells and whistles.
Last updated 10 years ago by ppaskaris .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install faster-stable-stringify 
SYNC missed versions from official npm registry.

faster-stable-stringify

Faster deterministic JSON.stringify() without bells and whistles.

const stableStringify = require('faster-stable-stringify');

const json = stableStringify({greetings: 'Hello!', apples: 'bananas'});
// json = {"apples":"bananas","greetings":"Hello!"}

Installation

$ npm install faster-stable-stringify

Features

  • JSON.stringify that has deterministic output
  • Handles edge cases in accordance with the spec
  • Replaces cycles with "[Circular]" similar to isaac's json-stringify-safe

API

A single function is exported.

stableStringify(value)

The behavior is identical to the native JSON.stringify, excluding circular structures. See here for an explanation of the JSON.stringify behavior.

Alternatives

If you need to customize the sorting behavior, or want an implementation that throws on circular references, you may prefer to use substack's json-stable-stringify.

If you need it to work in the browser or in an environment without a native JSON.stringify, you may prefer to use nickyout's fast-stable-stringify.

Current Tags

  • 1.0.0                                ...           latest (10 years ago)

1 Versions

  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 5
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE