MCPcopy
hub / github.com/Effect-TS/effect / many

Function many

packages/printer/src/internal/docTree.ts:387–404  ·  view source on GitHub ↗
(parser: DocTreeParser<S, A>)

Source from the content-addressed store, hash-verified

385 Option.flatMap(self(stream), ([a, s1]) => f(a)(s1))
386
387function many<S, A>(parser: DocTreeParser<S, A>): DocTreeParser<S, ReadonlyArray<A>> {
388 return (stream) =>
389 pipe(
390 parser(stream),
391 Option.map(([head, next]) => {
392 const output: Array<A> = [head]
393 let input: S = next
394 let result = parser(next)
395 while (result._tag === "Some") {
396 const [value, nextInput] = result.value
397 output.push(value)
398 input = nextInput
399 result = parser(nextInput)
400 }
401 return [output, input] as const
402 })
403 )
404}
405
406const nextToken = <A>(): DocTreeParser<DocStream.DocStream<A>, docTreeToken.DocTreeToken<A>> => {
407 return (stream) => {

Callers 1

parserFunction · 0.85

Calls 3

parserFunction · 0.85
pipeFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected