| 91 | .trim() |
| 92 | .match(/^\((.*)\)\s*(?:[a-z_]+(?:\s+[a-z_]+)*\s*)?->/); |
| 93 | if (!match) return 'unknown'; |
| 94 | const args = match[1].trim(); |
| 95 | if (args === '') return '0'; |
| 96 | // Split, and read the optional/variadic markers, at the TOP LEVEL only. A |
| 97 | // parameter type can carry commas and markers of its own — |
| 98 | // `reducer: (unknown, T) any -> unknown` is ONE parameter, and a naive |
| 99 | // `split(',')` counted `Fold` as 4-ary. |
| 100 | const params = topLevelParams(args); |
| 101 | if (params.some((p) => /[*+]$/.test(p))) return 'variadic'; |
| 102 | if (params.some((p) => p.endsWith('?'))) return 'optional'; |
| 103 | return String(params.length); |
| 104 | } |
| 105 | |
| 106 | /** `args` split on the commas that separate PARAMETERS — those outside any |
| 107 | * `(`, `<` or `[` group. The `>` of an ARROW (`->`) closes nothing: without |