hapijs / hoek

Node utilities shared among the extended hapi universe
Other
480 stars 171 forks source link

Fix clone of subclassed Set and Map #302

Closed kanongil closed 5 years ago

kanongil commented 5 years ago

I just wanted to fix the harmless double seen.set() for Set and Map clones introduced in #301, but found a new bug: Hoek.clone() does not transfer the prototype of a subclassed Set or Map.

I did a fix for this, but found that objects created using Object.create(proto) are broken. Instead I ended up at this, where I create a base object, and change its prototype (if required).

There is a lot of changes here, but most is refactoring to make a somewhat clean and performant implementation.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.