Skip to content

v2.5.0

Latest
Compare
Choose a tag to compare
@BridgeAR BridgeAR released this 01 Aug 17:32
· 1 commit to main since this release
  • 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!