-
-
Notifications
You must be signed in to change notification settings - Fork 43
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 copies prototype properties onto the object #14
Comments
Thank you This will be included in the default & upcoming "full" modes. |
@lukeed can we fix it? Blocker for fully migrate on klona |
Yup, I have a solution to this now. Had to spend some time on it so that performance didn't take too much of a blow. This will be included in 1.1.2 and then I will immediately begin moving to 2.0.0 with #13 in mind. |
Hey @evilebottnawi – I'm not sure what you're switching from, but I'm guessing it's You can see this here: const clone = require('clone-deep');
const klona = require('klona');
function Test () {}
Test.prototype.val = 42;
function run(name, lib) {
let input = new Test();
let output = lib(input);
console.log('[%s] before:', name, output.val);
input.val++; // modify source
console.log('[%s] after:', name, output.val);
}
run('clone-deep', clone);
run('clone-deep (instance)', foo => clone(foo, true));
run('klona', klona);
//=> [clone-deep] before: 42
//=> [clone-deep] after: 43
//=> [clone-deep (instance)] before: 42
//=> [clone-deep (instance)] after: 42
//=> [klona] before: 42
//=> [klona] after: 42 |
Awesome! Thank you! |
The text was updated successfully, but these errors were encountered: