Skip to content

Instantly share code, notes, and snippets.

@glued
Created March 8, 2019 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glued/d2992079361f9ce85972d51f52938757 to your computer and use it in GitHub Desktop.
Save glued/d2992079361f9ce85972d51f52938757 to your computer and use it in GitHub Desktop.
Deep Copy Decorator
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