deep-clone-fn
v1.1.0
Published
Deep clone a function.
Downloads
2,619
Readme
deep-clone-fn
A modification of Sindre Sorhus's excellent mimic-fn for deep cloning functions.
Installation
npm install deep-clone-fn
Usage
import deepCloneFunction from 'deep-clone-fn';
function f(x) {
return x;
}
f.myProperty = { foo: 'bar' };
const g = deepCloneFunction(f);
f.myProperty.foo = 'baz';
console.log(g.myProperty); // { foo: 'bar' }
console.log(g('foo')); // foo