Package Exports
- function-regex
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 (function-regex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Function regex. Regular expression for matching function parts. Expose match groups for function name, arguments and function body.
Install
npm install function-regex
npm test
Usage
For more use-cases see the tests
var functionRegex = require('function-regex');
var fixture = function testing(args, opts, dest, cb) {
return cb ? {
opts: [1,2,3]
} : true;
};
fixture.toString().match(functionRegex());
//=> [1] = 'testing'
//=> [2] = 'args, opts, dest, cb'
//=> [3] = '\n return cb ? {\n opts: [1,2,3],\n args: args\n } : true;\n '
'function(val, re) { return true; }'.match(functionRegex());
//=> [1] = ''
//=> [2] = 'val, re'
//=> [3] = ' return true; '
Matching groups
[0]
full function ('function(val, re) { return true; }'
)[1]
function name ('testing'
)[2]
function arguments ('args, opts, dest, cb'
)[3]
function body (' return true; '
)
Author
Charlike Mike Reagent
License 
Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
Released under the MIT
license.
Powered and automated by kdf, January 27, 2015