-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloning a class that extends Map, e.g. a "DefaultMap", returns a Map instead #87
Comments
i came across this issue just now.
|
Running into the same problem, any updates? |
same problem, can you fix it |
If you don't need to use this specific library, I have found that lodash's cloneDeep() works best. It supports classes that inherit from Map. https://lodash.com/docs/#cloneDeep I wrote a comparison of some JS (NodeJS) cloning libraries back in 2018, here's one view of the results: https://laurence-myers.github.io/clone-comparison-nodejs/index.html#section-feature-table |
@laurence-myers I will give it a try, thx any way. |
I have a custom class that extends from Map. This class is "DefaultMap", and provides a default value when an item is not found in the Map.
It looks like instances of "DefaultMap" are getting cloned as just "Map". It then loses the custom functionality provided by "DefaultMap".
Here's a test case in Mocha to reproduce the problem:
The test fails at the assertion "The overriding method on DefaultMap should be called".
Tested in clone v2.1.1, Node v6.9.1.
The text was updated successfully, but these errors were encountered: