({ left, right }: {
readonly left: Left
readonly right: Right
})
| 7530 | * @since 3.10.0 |
| 7531 | */ |
| 7532 | export const EitherFromUnion = <Right extends Schema.All, Left extends Schema.All>({ left, right }: { |
| 7533 | readonly left: Left |
| 7534 | readonly right: Right |
| 7535 | }): EitherFromUnion<Right, Left> => { |
| 7536 | const right_ = asSchema(right) |
| 7537 | const left_ = asSchema(left) |
| 7538 | const toright = typeSchema(right_) |
| 7539 | const toleft = typeSchema(left_) |
| 7540 | const fromRight = transform(right_, rightEncoded(toright), { |
| 7541 | strict: true, |
| 7542 | decode: (i) => makeRightEncoded(i), |
| 7543 | encode: (a) => a.right |
| 7544 | }) |
| 7545 | const fromLeft = transform(left_, leftEncoded(toleft), { |
| 7546 | strict: true, |
| 7547 | decode: (i) => makeLeftEncoded(i), |
| 7548 | encode: (a) => a.left |
| 7549 | }) |
| 7550 | const out = transform( |
| 7551 | Union(fromRight, fromLeft), |
| 7552 | EitherFromSelf({ left: toleft, right: toright }), |
| 7553 | { |
| 7554 | strict: true, |
| 7555 | decode: (i) => i._tag === "Left" ? either_.left(i.left) : either_.right(i.right), |
| 7556 | encode: (a) => |
| 7557 | either_.match(a, { |
| 7558 | onLeft: makeLeftEncoded, |
| 7559 | onRight: makeRightEncoded |
| 7560 | }) |
| 7561 | } |
| 7562 | ) |
| 7563 | return out as any |
| 7564 | } |
| 7565 | |
| 7566 | const mapArbitrary = <K, V>( |
| 7567 | key: LazyArbitrary<K>, |
nothing calls this directly
no test coverage detected
searching dependent graphs…