@leismore/jsonify_function
v3.0.2
Published
Convert a JavaScript function into a stringified JSON string.
Downloads
22
Maintainers
Readme
jsonify_function
Convert a JavaScript function into a stringified JSON string.
Donation
Motivation
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.
Installation
npm install @leismore/jsonify_function
Test
npm test
Usage
import {jsonify_function} from '@leismore/jsonify_function';
// Define your function here
function test()
{
console.log('test');
}
// Output
console.log( jsonify_function(test) );
License
GNU Affero General Public License v3.0
Authors
Kyle Chine (Initial Author)