MCPcopy Create free account
hub / github.com/Effect-TS/effect / splitIndexFrom

Function splitIndexFrom

packages/effect/src/internal/configProvider.ts:698–715  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

696}
697
698const 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
717const parseInteger = (str: string): Option.Option<number> => {
718 const parsedIndex = Number.parseInt(str)

Callers 1

splitIndexInKeysFunction · 0.85

Calls 1

pipeFunction · 0.70

Tested by

no test coverage detected