UNPKG

chai-latte

Version:

Build expressive & readable fluent interface libraries.

17 lines 803 B
"use strict"; // https://stackoverflow.com/questions/1007981/how-to-get-function-parameter-names-values-dynamically Object.defineProperty(exports, "__esModule", { value: true }); exports.extractArguments = void 0; function extractArguments(func) { return (func + '') .replace(/[/][/].*$/mg, '') // strip single-line comments .replace(/\s+/g, '') // strip white space .replace(/[/][*][^/*]*[*][/]/g, '') // strip multi-line comments .split('){', 1)[0].replace(/^[^(]*[(]/, '') // extract the parameters .replace(/=[^,]+/g, '') // strip any ES6 defaults .split(',') .filter(Boolean) // split & filter [""] .map(t => t.replace(/\)$/g, '')); } exports.extractArguments = extractArguments; //# sourceMappingURL=extractArguments.js.map