flightcontrolhq / superjson

Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.
https://www.flightcontrol.dev?ref=superjson
MIT License
4.13k stars 91 forks source link

are superjson strings stable/deterministic? #226

Closed smolattack closed 1 year ago

smolattack commented 1 year ago
import {stringify} from "superjson"

const str = stringify({a: 1, b:2})
// str is '{"json":{"a":1,"b":2}}'

Could str ever be '{"json":{"b":2,"a":1}}'?

Thanks

Skn0tt commented 1 year ago

I wouldn't depend on that, since it depends on the behaviour of a number of platform primitives like JSON.stringify or Object.entries, which could be different e.g. between Node.js and Deno.