(input: string, patterns: Record<string, any>)
| 19 | } |
| 20 | |
| 21 | export function all(input: string, patterns: Record<string, any>) { |
| 22 | const sorted = pipe(patterns, Object.entries, sortBy([([key]) => key.length, "asc"], [([key]) => key, "asc"])) |
| 23 | let result = undefined |
| 24 | for (const [pattern, value] of sorted) { |
| 25 | if (match(input, pattern)) { |
| 26 | result = value |
| 27 | continue |
| 28 | } |
| 29 | } |
| 30 | return result |
| 31 | } |
| 32 | |
| 33 | export function allStructured(input: { head: string; tail: string[] }, patterns: Record<string, any>) { |
| 34 | const sorted = pipe(patterns, Object.entries, sortBy([([key]) => key.length, "asc"], [([key]) => key, "asc"])) |
no test coverage detected