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

Function allTupled

packages/cli/src/internal/prompt.ts:71–88  ·  view source on GitHub ↗
(arg: T)

Source from the content-addressed store, hash-verified

69 typeof u === "object" && u != null && PromptTypeId in u
70
71const allTupled = <const T extends ArrayLike<Prompt.Prompt<any>>>(arg: T): Prompt.Prompt<
72 {
73 [K in keyof T]: [T[K]] extends [Prompt.Prompt<infer A>] ? A : never
74 }
75> => {
76 if (arg.length === 0) {
77 return succeed([]) as any
78 }
79 if (arg.length === 1) {
80 return map(arg[0], (x) => [x]) as any
81 }
82 let result = map(arg[0], (x) => [x])
83 for (let i = 1; i < arg.length; i++) {
84 const curr = arg[i]
85 result = flatMap(result, (tuple) => map(curr, (a) => [...tuple, a]))
86 }
87 return result as any
88}
89
90/** @internal */
91export const all: <

Callers 1

allFunction · 0.70

Calls 2

succeedFunction · 0.70
mapFunction · 0.50

Tested by

no test coverage detected