Package Exports
- parse-function
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 (parse-function) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Parse a given function or string (fn.toString()) to object with
name,argsandbodyproperties.
Install
npm install parse-function
npm testAPI
For more use-cases see the tests
parseFunction
Parse given function or string to object with properties
name,args,argumentsandbody
[fn]{Function|String}return{Object}namefunction name oranonymousargsfunction arguments names as array (['val', 're', 'beta']) or''argumentsfunction arguments as string (val, re, beta) or''bodyfunction body as string or''
Example:
var parseFunction = require('parse-function');
var fixture = 'function testing(val, re, beta) { return true; }';
var actual = parseFunction(fixture);
//=> actual = {
// name: 'testing',
// args: ['val', 're', 'beta'],
// arguments: 'val, re, beta',
// body: ' return true; '
//};
var unnamed = function() {};
var res = parseFunction(unnamed);
//=> res = {
// name: 'anonymous',
// args: [],
// arguments: '',
// body: ''
//};Author
Charlike Mike Reagent
License 
Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Released under the MIT license.
Powered and automated by kdf, January 26, 2015