NodeJS: Deep copy a function
<p>Is it possible to deep copy a function object in NodeJS?  I am trying to use a function that I have set fields on, but I need a way to copy that function so that when I do duplicate it, I can modify these extra fields separately.</p>

<p>For example:</p>

<pre><code>let a = function(){console.log('hello world')}
a.__var = 1
let b = clone(a)
a.__var // 1
b.__val // 1
b.__var = 2
a.__var // 1
</code></pre>

<p>I've tried things like using underscore/lodash, but they seem to convert the function to an object in the clone.  <code>b</code> would wind up being <code>{ __var: 1 }</code> in the previous example.  I need to be able to perform a deep copy on the function..</p>