function-code

1.0.0 • Public • Published

function-code Build Status

Turn functions into strings

npm install function-code
var functionCode = require('function-code');

functionCode(fn, args...)

console.log(functionCode(function (a, b) {
    return a + b;
}, 2, 2));

Outputs

(function (a, b) {
    return a + b;
}(2,2))

functionCode.inline(fn, args...)

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);

functionCode.code(fn, args...)

Alias to functionCode(fn, args...)

Function.prototype.toCode(args...)

Alias to functionCode(this, args...)

Function.prototype.toInline()

Alias to functionCode.inline(this)

Package Sidebar

Install

npm i function-code

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • munro