title: Convert function source code to a string in NodeJS/JavaScript
body: <p>I am creating JavaScript functions for map/reduce operations on database server side. To have syntax highlighting and errors check I make it like this inside my text editor:</p>
  
  <pre><code>var map = function (doc, meta) {
    emit([doc.type, doc.created], doc);
  };
  </code></pre>
  
  <p>Then I need to somehow turn it into a string variable so that to add it as a view to Couchbase looking like this:</p>
  
  <pre><code>var map = "function (doc, meta) { emit([doc.type, doc.created], doc); };"
  </code></pre>
  
  <p>Is that possible to convert the source code to a string somehow?</p>