(key: string)
| 696 | } |
| 697 | |
| 698 | const splitIndexFrom = (key: string): Option.Option<[string, number]> => { |
| 699 | const match = key.match(STR_INDEX_REGEX) |
| 700 | if (match !== null) { |
| 701 | const matchedString = match[1] |
| 702 | const matchedIndex = match[3] |
| 703 | const optionalString = matchedString !== undefined && matchedString.length > 0 ? |
| 704 | Option.some(matchedString) : |
| 705 | Option.none() |
| 706 | const optionalIndex = pipe( |
| 707 | matchedIndex !== undefined && matchedIndex.length > 0 ? |
| 708 | Option.some(matchedIndex) : |
| 709 | Option.none(), |
| 710 | Option.flatMap(parseInteger) |
| 711 | ) |
| 712 | return Option.all([optionalString, optionalIndex]) |
| 713 | } |
| 714 | return Option.none() |
| 715 | } |
| 716 | |
| 717 | const parseInteger = (str: string): Option.Option<number> => { |
| 718 | const parsedIndex = Number.parseInt(str) |
no test coverage detected