| 1684 | > |
| 1685 | : [I] extends [Iterable<Option<infer A>>] ? Option<Array<A>> |
| 1686 | : Option<{ -readonly [K in keyof I]: [I[K]] extends [Option<infer A>] ? A : never }> = ( |
| 1687 | input: Iterable<Option<any>> | Record<PropertyKey, Option<any>> |
| 1688 | ): Option<any> => { |
| 1689 | if (Symbol.iterator in input) { |
| 1690 | const out: Array<Option<any>> = [] |
| 1691 | for (const o of (input as Iterable<Option<any>>)) { |
| 1692 | if (isNone(o)) { |
| 1693 | return none() |
| 1694 | } |
| 1695 | out.push(o.value) |
| 1696 | } |
| 1697 | return some(out) |
| 1698 | } |
| 1699 | |
| 1700 | const fields = input as Record<PropertyKey, Option<any>> |
| 1701 | const out: Record<PropertyKey, any> = {} |
| 1702 | for (const key of InternalRecord.ownEnumerableKeys(fields)) { |
| 1703 | const o = fields[key] |
| 1704 | if (isNone(o)) { |
| 1705 | return none() |
| 1706 | } |
| 1707 | InternalRecord.assignProperty(out, key, o.value) |
| 1708 | } |
| 1709 | return some(out) |
| 1710 | } |
| 1711 | |
| 1712 | /** |
| 1713 | * Combines two `Option`s using a provided function. |