| 1393 | > |
| 1394 | : [I] extends [Iterable<Option<infer A>>] ? Option<Array<A>> |
| 1395 | : Option<{ -readonly [K in keyof I]: [I[K]] extends [Option<infer A>] ? A : never }> = ( |
| 1396 | input: Iterable<Option<any>> | Record<string, Option<any>> |
| 1397 | ): Option<any> => { |
| 1398 | if (Symbol.iterator in input) { |
| 1399 | const out: Array<Option<any>> = [] |
| 1400 | for (const o of (input as Iterable<Option<any>>)) { |
| 1401 | if (isNone(o)) { |
| 1402 | return none() |
| 1403 | } |
| 1404 | out.push(o.value) |
| 1405 | } |
| 1406 | return some(out) |
| 1407 | } |
| 1408 | |
| 1409 | const out: Record<string, any> = {} |
| 1410 | for (const key of Object.keys(input)) { |
| 1411 | const o = input[key] |
| 1412 | if (isNone(o)) { |
| 1413 | return none() |
| 1414 | } |
| 1415 | out[key] = o.value |
| 1416 | } |
| 1417 | return some(out) |
| 1418 | } |
| 1419 | |
| 1420 | /** |
| 1421 | * Combines two `Option` values into a new `Option` by applying a provided |