Convert a JavaScript function into a stringified JSON string.
CouchDB design document architecture requires that all database handlers (JavaScript functions) are stored in a JSON structure. Functions in the JSON structure must be presented as escaped stringified strings. Similar as this:
{
"updatefun": "function test(a)\n{\n console.log('test');\n}"
}
CouchDB itself does not provide a tool for convert JavaScript functions to the JSON structure. So I wrote this simple command-line converter.
npm install @leismore/jsonify_function
npm test
import {jsonify_function} from '@leismore/jsonify_function';
// Define your function here
function test()
{
console.log('test');
}
// Output
console.log( jsonify_function(test) );GNU Affero General Public License v3.0
Kyle Chine (Initial Author)
