Rich-Harris / devalue

Gets the job done when JSON.stringify can't
https://svelte.dev/repl/138d70def7a748ce9eda736ef1c71239?version=3.49.0
MIT License
2.14k stars 57 forks source link

What is the difference between devalue and superjson? #75

Open martinszeltins opened 8 months ago

martinszeltins commented 8 months ago

I know this is not an "issue" but I don't understand what exactly is the difference between these 2 packages. Which is is better because they seem to do very similar things 😕

controversial commented 2 months ago

Functionality difference: superjson supports more types of values out of the box (e.g. classes, symbols, Errors, TypedArrays) that devalue doesn’t support

Safety difference: superjson ignores values it doesn’t support, silently excluding them from the output, whereas devalue throws an error. Erroring is probably better for type safety and predictable behavior, because you’ll be able to notice the error and add a custom replacer