Turn functions into strings
npm install function-code
var functionCode = require('function-code');
console.log(functionCode(function (a, b) {
return a + b;
}, 2, 2));
Outputs
(function (a, b) {
return a + b;
}(2,2))
var functionCode = require('function-code');
console.log(functionCode.inline(function (a, b) {
var a = 1,
b = 2;
console.log('a + b = ', a + b);
}));
Outputs
var a = 1,
b = 2;
console.log('a + b = ', a + b);
Alias to functionCode(fn, args...)
Alias to functionCode(this, args...)
Alias to functionCode.inline(this)