davidmarkclements / rfdc

Really Fast Deep Clone
MIT License
635 stars 24 forks source link

Support for Map and Set types #17

Closed derekparsons718 closed 3 years ago

derekparsons718 commented 3 years ago

I would love to see support added for the native Map and Set types.

They are becoming increasingly popular and I use them all the time. But the current behavior when cloning them is to return an empty object:

const data = {
    set: new Set([1, 2, 3]),
    map: new Map([
        ["a", 1],
        ["b", 2],
        ["c", 3]
    ])
};
console.log(data); // {set: {1, 2, 3}, map: {"a" => 1, "b" => 2, "c" => 3}}
console.log(clone(data)); // {set: {}, map: {}}
davidmarkclements commented 3 years ago

PR's for this are more than welcome!