( argumentNames: string | string[] | undefined, )
| 50 | * - ["foo", "bar", "baz"] => ["foo", "bar", "baz"] |
| 51 | */ |
| 52 | export function parseArgumentNames( |
| 53 | argumentNames: string | string[] | undefined, |
| 54 | ): string[] { |
| 55 | if (!argumentNames) { |
| 56 | return [] |
| 57 | } |
| 58 | |
| 59 | // Filter out empty strings and numeric-only names (which conflict with $0, $1 shorthand) |
| 60 | const isValidName = (name: string): boolean => |
| 61 | typeof name === 'string' && name.trim() !== '' && !/^\d+$/.test(name) |
| 62 | |
| 63 | if (Array.isArray(argumentNames)) { |
| 64 | return argumentNames.filter(isValidName) |
| 65 | } |
| 66 | if (typeof argumentNames === 'string') { |
| 67 | return argumentNames.split(/\s+/).filter(isValidName) |
| 68 | } |
| 69 | return [] |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Generate argument hint showing remaining unfilled args. |
no outgoing calls
no test coverage detected