title: Underscore.js: how to chain custom functions
body: <p>Using <a href="http://documentcloud.github.com/underscore/" rel="noreferrer">Underscore.js</a>, I can write the following which returns <code>42</code>:</p>
  
  <pre><code>_([42, 43]).chain()
      .first()
      .value()
  </code></pre>
  
  <p>I have custom function, not part of Underscore.js called <code>double()</code>:</p>
  
  <pre><code>function double(value) { return value * 2; };
  </code></pre>
  
  <p>I would like to be able to call this function in an Underscore chain, as if it was part of Underscore. I would like to write the following, which I'd like to return <code>84</code>:</p>
  
  <pre><code>_([42, 43]).chain()
      .first()
      .double()
      .value()
  </code></pre>
  
  <p>This can't work since Underscore doesn't define <code>double()</code>. I could use <a href="http://documentcloud.github.com/underscore/#tap" rel="noreferrer"><code>tap()</code></a> as in:</p>
  
  <pre><code>_([42, 43]).chain()
      .first()
      .tap(double)
      .value()
  </code></pre>
  
  <p>This is valid, but <code>tap</code> applies the function to its argument and returns the argument, not the result of the function. So it looks to me like I would need a sort of <code>tap</code> that returns the result of the function applied to its argument. Is there anything like this in Underscore.js? Am I missing something terribly obvious?</p>