Closed
Description
Currently the only requirement for data
property is stringifiability which is defined as follows:
Its only limitation being that each property should by stringifyable: not throw when passed to
JSON.stringify()
.
I think this is too broad, in particular because JSON.stringify
won't usually throw:
> JSON.stringify({ foo: function () { console.log('foo') }})
'{}'
> JSON.stringify({ foo: undefined })
'{}'
I was worried about this when hacking on unist-builder-blueprint: there is no reliable way to compile functions to source code (with closures and stuff like heap references), so a more strict guarantee like "data and JSON.parse(JSON.stringify(data)) should be equivalent and interchangeable" or even deepEqual(JSON.parse(JSON.stringify(data)), data)
would be helpful.