UNPKG

832 BJavaScriptView Raw
1"use strict";
2// [注释匹配](https://blog.csdn.net/sodino/article/details/51386113)
3Object.defineProperty(exports, "__esModule", { value: true });
4var commentMath = /(\/\/.*)|(\/\*[\s\S]*?\*\/)/g;
5// const argsMath = /function.*?\(([^)]*)\)/; //
6var argsMath = /.*?\(([^)]*)\)/;
7var argMath = /[a-z0-9A-Z_]+/;
8function argnames(func) {
9 var funcStr = func.toString().replace(commentMath, ""); // 去除注释
10 var matchArray = funcStr.match(argsMath); // 匹配左右括号获取所有参数
11 return matchArray[1]
12 .split(",") // 分割参数
13 .filter(function (arg) {
14 return arg.trim(); // 过滤掉空的字段
15 })
16 .map(function (arg) {
17 return arg.match(argMath)[0]; // 匹配参数名
18 });
19}
20exports.default = argnames;
21//# sourceMappingURL=index.js.map
\No newline at end of file