Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 - npm Package Versions

2

2.5.0

Diff

Changelog

Source

v2.5.0

  • Accept Array#sort(comparator) comparator method as deterministic option value to use that comparator for sorting object keys.
import { configure } from 'safe-stable-stringify'

const object = {
  a: 1,
  b: 2,
  c: 3,
}

const stringify = configure({
  deterministic: (a, b) => b.localeCompare(a)
})

stringify(object)
// '{"c":3,"b":2,"a":1}'
  • Very minor performance optimization.

Thanks to @flobernd, @cesco69 and @prisis to contribute to this release!

bridgear
published 2.4.3 •

Changelog

Source

v2.4.3

  • Fixed toJSON function receiving array keys as number instead of string
  • Fixed replacer function receiving array keys as number instead of string
  • Fixed replacer function not being called for TypedArray entries
  • Improved performance to escape long strings that contain characters that need escaping
bridgear
published 2.4.2 •

Changelog

Source

v2.4.2

  • Improved ESM TypeScript types.
  • More precise TypeScript replacer type.
bridgear
published 2.4.1 •

Changelog

Source

v2.4.1

  • More precise TypeScript types. The return type is now either string, undefined or string | undefined depending on the input.
bridgear
published 2.4.0 •

Changelog

Source

v2.4.0

  • Added strict option to verify that the passed in objects are fully compatible with JSON without removing information. If not, an error is thrown.
  • Fixed TypeScript definition for ESM code bases
bridgear
published 2.3.1 •

Changelog

Source

v2.3.1

  • Fix invalid regexp group error in browsers or environments that do not support the negative lookbehind regular expression assertion.
bridgear
published 2.3.0 •

Changelog

Source

v2.3.0

  • Accept the Error constructor as circularValue option to throw on circular references as the regular JSON.stringify would:
import { configure } from 'safe-stable-stringify'

const object = {}
object.circular = object;

const stringify = configure({ circularValue: TypeError })

stringify(object)
// TypeError: Converting circular structure to JSON
  • Fixed escaping wrong surrogates. Only lone surrogates are now escaped.
bridgear
published 2.2.0 •

Changelog

Source

v2.2.0

  • Reduce module size by removing the test and benchmark files from the published package
  • Accept undefined as circularValue option to remove circular properties from the serialized output:
import { configure } from 'safe-stable-stringify'

const object = { array: [] }
object.circular = object;
object.array.push(object)

configure({ circularValue: undefined })(object)
// '{"array":[null]}'
bridgear
published 2.1.0 •

Changelog

Source

v2.1.0

  • Added maximumBreadth option to limit stringification at a specific object or array "width" (number of properties / values)
  • Added maximumDepth option to limit stringification at a specific nesting depth
  • Implemented the well formed stringify proposal that is now part of the spec
  • Fixed maximum spacer length (10)
  • Fixed TypeScript definition
  • Fixed duplicated array replacer values serialized more than once
bridgear
published 2.0.0 •

Changelog

Source

v2.0.0

  • [BREAKING] Convert BigInt to number by default instead of ignoring these values If you wish to ignore these values similar to earlier versions, just use the new bigint option and set it to false.
  • [BREAKING] Support ESM
  • [BREAKING] Requires ES6
  • Optional BigInt support
  • Deterministic behavior is now optional
  • The value to indicate a circular structure is now adjustable
  • Significantly faster TypedArray stringification
  • Smaller Codebase
  • Removed stateful indentation to guarantee side-effect freeness
2
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