Package Exports
- js-function-reflector
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-function-reflector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
js-function-reflector
Function Reflection in Javascript With Support for ES6 Syntax and Babel Transpiled Code
Installation
npm install js-function-reflector
Usage
var functionReflector = require('js-function-reflector');
// If you are using babel transpiler
functionReflector = reflector.compiler('babel-preset-es2015');
Example
function a(foo, bar) {};
console.log(functionReflector(a));
// { name: 'a', args: [foo, bar], body: '' }
const b = (foo, bar = true, baz = 'string', qux = 3, ...quux) => {};
console.log(functionReflector(b));
// { name: 'anonymous', args: ['foo', ['bar', true], ['baz', 'string'], ['qux', 3], '...quux'], body: '' }
const b = (foo = [1, 2], bar = {a: 1, b : ['s', 't', 'r']}) => {};
// { name: 'anonymous', args: [['foo', [1, 2]], ['bar', {a: 1, b : ['s', 't', 'r']}]], body: '' }
const d = (foo) => {
return foo
}
console.log(functionReflector(d));
// { name: 'anonymous', args: ['foo'], body: 'return foo' }
const e = foo => 'bar'
console.log(functionReflector(e));
// { name: 'anonymous', args: ['foo'], body: "return 'bar'" }