Hacker News new | ask | show | jobs
by easyThrowaway 914 days ago
I guess there's some good reason nobody ever did it, but what about throwing an UnhandledType kind of error and letting the catch() decide how to deal with the object in question?
2 comments

On top of the compatibility issue mentioned in sibling comment, the existing behavior also matches the principle of keeping simple things simple without making complicated things impossible. If you want stringify with a check for unhandled elements, that's easily specified in a replacer (that does not really replace).

You might prefer some well established standard implementation over ad hoc roll your own, but that's a discussion about npm culture, not about stringify.

Browser care about compatibility a lot, the ship to change this behavior has shipped a long time ago.