| 690 | export 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 | |
| 724 | const annotateLine = (line: string): string => Ansi.annotate(line, Ansi.bold) |
| 725 | const annotateErrorLine = (line: string): string => Ansi.annotate(line, Ansi.combine(Ansi.italicized, Ansi.red)) |