Closed JamieMagee closed 1 year ago
The provided code seems to pass for me. I have added a test for this that passes: https://github.com/sindresorhus/is/commit/9265e9072d512ab1188c1d6347bc46c287775a93
I think the root cause of this may be me using version 4.x, and plainObject
improvements here: https://github.com/sindresorhus/is/commit/45cae31f4d7311d8ae1250558e710594acff7d01
Thanks for the help
structuredClone
was added as a global function in Node 17 as a built-in way to deep-clone objects. However, one of the limitations of the structured clone algorithm is that it doesn't clone the prototype chain^1.isPlainObject
explicitly compares values with the prototype ofObject
^2 which means that objects cloned withstructuredClone
always return false. This is called out in the documentation, so I don't necessarily think it's a bugBut I also think that
is.object
is too broad, andis.emptyObject
/is.nonEmptyObject
are perhaps too precise. Some options I've considered:is.plainObject
should return true for objects cloned withstructuredClone
?is.clonedObject
?But I would like to get your input.
Here's a small repro: