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

Function all

packages/cli/src/internal/prompt.ts:93–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91export const all: <
92 const Arg extends Iterable<Prompt.Prompt<any>> | Record<string, Prompt.Prompt<any>>
93>(arg: Arg) => Prompt.All.Return<Arg> = function() {
94 if (arguments.length === 1) {
95 if (isPrompt(arguments[0])) {
96 return map(arguments[0], (x) => [x]) as any
97 } else if (Array.isArray(arguments[0])) {
98 return allTupled(arguments[0]) as any
99 } else {
100 const entries = Object.entries(arguments[0] as Readonly<{ [K: string]: Prompt.Prompt<any> }>)
101 let result = map(entries[0][1], (value) => ({ [entries[0][0]]: value }))
102 if (entries.length === 1) {
103 return result as any
104 }
105 const rest = entries.slice(1)
106 for (const [key, prompt] of rest) {
107 result = result.pipe(
108 flatMap((record) =>
109 prompt.pipe(map((value) => ({
110 ...record,
111 [key]: value
112 })))
113 )
114 )
115 }
116 return result as any
117 }
118 }
119 return allTupled(arguments[0]) as any
120}
121
122/** @internal */
123export const custom = <State, Output>(

Callers

nothing calls this directly

Calls 5

entriesMethod · 0.80
isPromptFunction · 0.70
allTupledFunction · 0.70
pipeMethod · 0.65
mapFunction · 0.50

Tested by

no test coverage detected