A modification of Sindre Sorhus's excellent mimic-fn for deep cloning functions.
npm install deep-clone-fn
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