(func: (...args: any[]) => any, cache?: boolean)
| 16 | * @return {Array} names |
| 17 | */ |
| 18 | export function getParamNames(func: (...args: any[]) => any, cache?: boolean): string[] { |
| 19 | const type = typeof func; |
| 20 | assert.equal(type, 'function', `The "func" must be a function. Received type "${type}"`); |
| 21 | |
| 22 | cache = cache !== false; |
| 23 | if (cache && '__cache_names' in func) { |
| 24 | return func.__cache_names as string[]; |
| 25 | } |
| 26 | const str = func.toString(); |
| 27 | const names = str.slice(str.indexOf('(') + 1, str.indexOf(')')).match(/([^\s,]+)/g) || []; |
| 28 | Reflect.set(func, '__cache_names', names); |
| 29 | return names; |
| 30 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…