title: Overriding a function's toString() in node exports
body: <p>I am trying to override a toString() method, but getting into difficulties.
  Already looked <a href="https://stackoverflow.com/questions/21805263/node-js-overriding-tostring">here</a> and <a href="https://stackoverflow.com/questions/6307514/is-it-possible-to-override-javascripts-tostring-function-to-provide-meaningfu">here</a>, but still no luck.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>var Foo = function(arg) {
      // some code here...
  
      return function (a, b, c) {
         // return function code...
      };
  };
  
  Foo.prototype.toString = function () {
      return "string representation of function";
  };
  
  exports.bar(arg) {
      return Foo(arg);
  };
  </code></pre>
  
  <p>In another module:</p>
  
  <pre><code>var mod = require('the-module-from-above');
  console.log(mod.bar().toString()); // prints return function source code.
  </code></pre>
  
  <p>My question is, how come my toString() function isn't called, and how can I make it get called?</p>
  
  <p>thank you.</p>