Trying to clone a hash generated by the node crypto package throws an error, whereas in lodash it handles it just fine. It appears that is because lodash uses toString-based tags to determine what clone to produce, which means a standard POJO is being created. Wrapping the new object.constructor() in a try prevents the error from occurring and allows the fallback of using Object.create to create the clone.
Trying to clone a
hash
generated by the nodecrypto
package throws an error, whereas inlodash
it handles it just fine. It appears that is because lodash usestoString
-based tags to determine what clone to produce, which means a standard POJO is being created. Wrapping thenew object.constructor()
in atry
prevents the error from occurring and allows the fallback of usingObject.create
to create the clone.Should fix #19