In couchdb, one can define map and reduce functions in Javascript, and submit them via HTTP POST to the server to define views. Cool.

Apps specify a string representation of the respective functions.

I am building a JS app that connects to couchdb, using emacs, a text editor. This lets me define map and reduce functions like this: 

```
var byname = function(doc) { 
   emit(doc.name,null);
};

```

This gives me emacs syntax highlighting, jslint checks, and so on. 

At runtime, I can get the string representation of each one of a set of view functions defined like that, to send it to CouchDB, by doing this: 

```
doc = { views: { empty:   { map:stringRep(empty) },
                 byname:  { map:stringRep(byname) },
                 invalid: { map:stringRep(invalid) }}};

// PUT that doc to couchdb here, to define the design_doc . 

```

But the string representations include newlines, carriage returns, and so on. 

I could filter those out with a regex replacement, which works for the simple case. 
But there is also the more complex case of commented lines in the function. For example: 

```
var byname = function(doc) { 
   // a comment here
   emit(doc.name,null);
};

```

In this case the stringRep will include the comment but if I eliminate the newlines and dummy whitespace, the comments remain. I could replace those too, but there may be other problems (not sure). 

**Is there a typical or recommended way that people sanitize their javascript functions before sending them to couchdb?**