( self: ReadonlyRecord<K, Either<R, L>> )
| 733 | * @since 2.0.0 |
| 734 | */ |
| 735 | export const getLefts = <K extends string, R, L>( |
| 736 | self: ReadonlyRecord<K, Either<R, L>> |
| 737 | ): Record<ReadonlyRecord.NonLiteralKey<K>, L> => { |
| 738 | const out: Record<string, L> = empty() |
| 739 | for (const key of keys(self)) { |
| 740 | const value = self[key] |
| 741 | if (E.isLeft(value)) { |
| 742 | out[key] = value.left |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | return out |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | * Given a record with `Either` values, returns a new record containing only the `Right` values, preserving the original keys. |