| 1627 | > |
| 1628 | : [I] extends [Iterable<Option<infer A>>] ? Option<Array<A>> |
| 1629 | : Option<{ -readonly [K in keyof I]: [I[K]] extends [Option<infer A>] ? A : never }> = ( |
| 1630 | input: Iterable<Option<any>> | Record<string, Option<any>> |
| 1631 | ): Option<any> => { |
| 1632 | if (Symbol.iterator in input) { |
| 1633 | const out: Array<Option<any>> = [] |
| 1634 | for (const o of (input as Iterable<Option<any>>)) { |
| 1635 | if (isNone(o)) { |
| 1636 | return none() |
| 1637 | } |
| 1638 | out.push(o.value) |
| 1639 | } |
| 1640 | return some(out) |
| 1641 | } |
| 1642 | |
| 1643 | const out: Record<string, any> = {} |
| 1644 | for (const key of Object.keys(input)) { |
| 1645 | const o = input[key] |
| 1646 | if (isNone(o)) { |
| 1647 | return none() |
| 1648 | } |
| 1649 | InternalRecord.assignProperty(out, key, o.value) |
| 1650 | } |
| 1651 | return some(out) |
| 1652 | } |
| 1653 | |
| 1654 | /** |
| 1655 | * Combines two `Option`s using a provided function. |