Created
March 8, 2019 05:11
-
-
Save glued/d2992079361f9ce85972d51f52938757 to your computer and use it in GitHub Desktop.
Deep Copy Decorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function DeepCopy() { | |
return function(target: any, key: string) { | |
let value = target[key]; | |
return Object.defineProperty(target, key, { | |
configurable: true, | |
get: () => value, | |
set: val => { | |
value = JSON.parse(JSON.stringify(val)); | |
}, | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment