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-function

Parse a function, arrow function or string to object with
name,args,paramsandbodyproperties.
Please read the CHANGELOG to see more info and the diffs between v2.0.1 and v2.1.0.
There's no breaking changes.
Install
npm i parse-function --saveUsage
For more use-cases see the tests
const parseFunction = require('parse-function')parseFunction
Parse function, arrow function or string to object.
[val]{Function|ArrowFunction|String} function or string to parsereturns{Object} withname,args,paramsandbodypropertiesname{String} name of the function oranonymousbody{String} body of the function or''params{String} arguments names as string (as is) or empty string''parameters{String} hidden property, alias ofparamsargs{Array} arguments names as array, or empty array[]arguments{Array} hidden property, alias ofargsvalue{String} hidden property, string representation of the givenvalorig{Function|ArrowFunction|String} hidden property, original givenvalvalid{Boolean} hidden property,truewhenvalis function or string,falseotherwiseinvalid{Boolean} hidden property, opposite ofopts.valid
Example
const parseFunction = require('parse-function')
const fixture = 'function testing (a, b, callback) { callback(null, a + b) }'
const obj = parseFunction(fixture)
// => {
// name: 'testing',
// body: ' callback(null, a + b) ',
// params: 'a, b, callback',
// args: ['a', 'b', 'callback']
// }
const withoutName = function (x, y) {}
const res = parseFunction(withoutName)
// => {
// name: 'anonymous',
// body: '',
// params: 'x, y',
// args: ['x', 'y']
// }Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.