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

Function all

packages/effect/src/unstable/cli/Prompt.ts:692–722  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

690export const all: <
691 const Arg extends Iterable<Prompt<any>> | Record<string, Prompt<any>>
692>(arg: Arg) => All.Return<Arg> = function() {
693 if (arguments.length === 1) {
694 if (isPrompt(arguments[0])) {
695 return map(arguments[0], (x) => [x]) as any
696 } else if (Predicate.isIterable(arguments[0])) {
697 return allTupled(Arr.fromIterable(arguments[0] as Iterable<Prompt<any>>)) as any
698 } else {
699 const entries = Object.entries(arguments[0] as Readonly<{ [K: string]: Prompt<any> }>)
700 if (entries.length === 0) {
701 return succeed({}) as any
702 }
703 let result = map(entries[0][1], (value) => ({ [entries[0][0]]: value }))
704 if (entries.length === 1) {
705 return result as any
706 }
707 const rest = entries.slice(1)
708 for (const [key, prompt] of rest) {
709 result = result.pipe(
710 flatMap((record) =>
711 prompt.pipe(map((value) => ({
712 ...record,
713 [key]: value
714 })))
715 )
716 )
717 }
718 return result as any
719 }
720 }
721 return allTupled(arguments[0]) as any
722}
723
724const annotateLine = (line: string): string => Ansi.annotate(line, Ansi.bold)
725const annotateErrorLine = (line: string): string => Ansi.annotate(line, Ansi.combine(Ansi.italicized, Ansi.red))

Callers 1

effect.tsFile · 0.50

Calls 5

mapFunction · 0.85
allTupledFunction · 0.85
isPromptFunction · 0.70
succeedFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected