| 742 | { -readonly [K in keyof I]: [I[K]] extends [Either<infer A, any>] ? A : never }, |
| 743 | I[keyof I] extends never ? never : [I[keyof I]] extends [Either<any, infer E>] ? E : never |
| 744 | > = ( |
| 745 | input: Iterable<Either<any, any>> | Record<string, Either<any, any>> |
| 746 | ): Either<any, any> => { |
| 747 | if (Symbol.iterator in input) { |
| 748 | const out: Array<Either<any, any>> = [] |
| 749 | for (const e of input) { |
| 750 | if (isLeft(e)) { |
| 751 | return e |
| 752 | } |
| 753 | out.push(e.right) |
| 754 | } |
| 755 | return right(out) |
| 756 | } |
| 757 | |
| 758 | const out: Record<string, any> = {} |
| 759 | for (const key of Object.keys(input)) { |
| 760 | const e = input[key] |
| 761 | if (isLeft(e)) { |
| 762 | return e |
| 763 | } |
| 764 | out[key] = e.right |
| 765 | } |
| 766 | return right(out) |
| 767 | } |
| 768 | |
| 769 | /** |
| 770 | * Returns an `Either` that swaps the error/success cases. This allows you to |