Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 25, 2024 via pnpm

safe-stable-stringify 2.4.3

Deterministic and safely JSON.stringify to quickly serialize JavaScript objects
Package summary
Share
0
issues
1
license
1
MIT
Package created
22 Jan 2018
Version published
19 Mar 2023
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
safe-stable-stringify@2.4.3
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of safe-stable-stringify 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does safe-stable-stringify do?

Safe-stable-stringify is a robust, efficient, and deterministic serialization alternative to the native JavaScript JSON.stringify method. This npm package is designed to handle potential JSON.stringify pitfalls like circular structures and BigInt values, as well as offering determinism and zero dependencies.

How do you use safe-stable-stringify?

To use safe-stable-stringify in your JavaScript application, first, you must install the library through npm by using the command npm install safe-stable-stringify. Once installed, you can import the stringify function into your JavaScript file and use it to serialize your JavaScript objects. Here's a simple usage example:

const stringify = require('safe-stable-stringify')
const bigint = { a: 0, c: 2n, b: 1 }
console.log(stringify(bigint)) // Outputs: '{"a":0,"b":1,"c":2}'

Besides basic usage, the safe-stable-stringify package allows custom configuration to define the behavior for circular references, BigInt values, and more. Here's an example showcasing these configurations in action:

import { configure } from 'safe-stable-stringify'

const stringify = configure({
  bigint: true,
  circularValue: 'Magic circle!',
  deterministic: false,
  maximumDepth: 1,
  maximumBreadth: 4
})

const circularObj = {
  bigint: 999_999_999_999_999_999n,
  circular: 'Circular reference!',
  ignored: true,
}

const stringifiedObj = stringify(circularObj, null, 4)

console.log(stringifiedObj)

This will output your object serialized to a string where any circular references are replaced by the string 'Magic circle!', and where the maximum depth and max breadth of the object to be included in the serialized string are defined.

Where are the safe-stable-stringify docs?

The detailed usage and configuration options of safe-stable-stringify are included within its readme file provided on the GitHub page. This readme file serves as the primary source of documentation, offering plenty of information on how to use the package and configure its various options, including handling of circular structures, BigInt values, object key ordering, and more. The readme also provides performance benchmarks comparing safe-stable-stringify with other known alternatives. Be sure to review this readme on GitHub to fully understand how to make the most out of the safe-stable-stringify package in your project.