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