unjs / defu

🌊 Assign default properties recursively
MIT License
1.06k stars 22 forks source link

clone support #90

Open pi0 opened 1 year ago

pi0 commented 1 year ago

Currently, we only create new object/array when both defaults and current value have a value while if only there is value here we set it.

I am thinking to introduce a new option to createDefu(merger, { clone: true } to enable cloning behavior.

An alternative would be using structuredClone however i think it also copies the values (non object/array) and taking more memory also not available in (at least Node) workers.