| 91 | export 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 */ |
| 123 | export const custom = <State, Output>( |