Socket
Socket
Sign inDemoInstall

safe-stable-stringify

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-stable-stringify

Deterministic and safely JSON.stringify to quickly serialize JavaScript objects


Version published
Weekly downloads
15M
increased by8.14%
Maintainers
1
Weekly downloads
 
Created

What is safe-stable-stringify?

The safe-stable-stringify npm package is used to convert JavaScript objects into a JSON string representation in a deterministic order. It ensures that objects with the same content will result in the same JSON string, regardless of the order in which their properties were defined. It also handles circular references and other edge cases that can cause JSON.stringify to throw errors.

What are safe-stable-stringify's main functionalities?

Deterministic JSON.stringify

This feature ensures that the JSON string output is consistent for the same object content, which is important for tasks like caching and comparison.

{"result": "safeStableStringify({ key1: 'value1', key2: 'value2' })"}

Handling circular references

safe-stable-stringify can handle objects that have circular references without throwing an error, unlike the native JSON.stringify.

{"result": "safeStableStringify(circularReference)"}

Custom replacer function

This feature allows for a custom replacer function to be used, similar to the replacer parameter in JSON.stringify, to customize the stringification process.

{"result": "safeStableStringify(obj, (key, value) => value instanceof RegExp ? String(value) : value)"}

Other packages similar to safe-stable-stringify

Keywords

FAQs

Package last updated on 24 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc