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

Function splitIndexFrom

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

Source from the content-addressed store, hash-verified

675}
676
677const splitIndexFrom = (key: string): Option.Option<[string, number]> => {
678 const match = key.match(STR_INDEX_REGEX)
679 if (match !== null) {
680 const matchedString = match[1]
681 const matchedIndex = match[3]
682 const optionalString = matchedString !== undefined && matchedString.length > 0 ?
683 Option.some(matchedString) :
684 Option.none()
685 const optionalIndex = pipe(
686 matchedIndex !== undefined && matchedIndex.length > 0 ?
687 Option.some(matchedIndex) :
688 Option.none(),
689 Option.flatMap(parseInteger)
690 )
691 return Option.all([optionalString, optionalIndex])
692 }
693 return Option.none()
694}
695
696const parseInteger = (str: string): Option.Option<number> => {
697 const parsedIndex = Number.parseInt(str)

Callers 1

splitIndexInKeysFunction · 0.85

Calls 1

pipeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…