blitz-js / superjson

Safely serialize JavaScript expressions to a superset of JSON, which includes Dates, BigInts, and more.
MIT License
3.88k stars 83 forks source link

Add support for complex Map key types #35

Closed Skn0tt closed 3 years ago

Skn0tt commented 3 years ago

Currently, SuperJSON is unable to serialise Map { /a/g => foo } or any other key type that's compared by reference. This is because there can be serialisability conflicts:

m = new Map()
m.set(/a/g, 1)
m.set(/a/g, 1)
m // Map { /a/g => 1, /a/g => 1 }

/* How do you serlialize this? */

Some other things that need to be accounted for when extending SuperJSON to serialise reference-compared values:

Skn0tt commented 3 years ago

Closed by #37