lukeed / klona

A tiny (240B to 501B) and fast utility to "deep clone" Objects, Arrays, Dates, RegExps, and more!
MIT License
1.62k stars 43 forks source link

Klona (JSON) preserves undefined #45

Open PointSingularity opened 6 months ago

PointSingularity commented 6 months ago

I am not sure if this is wanted behavior, but if there is an array that has undefined as an element it stays as undefined. JSON parse/stringify turns it into a null.

The same happens if a property is undefined, but with JSON it is completely stripped away.

In the README it says that undefined is only from supported from the lite, and JSON does not support undefined anyway.

Reproduction

I am assuming the way klona/json is intended to be used is we know in advance that our objects are JSON compatible in the first place, so this might be working as intended (but Map/Set are handled the same way as the JSON methods).