effect-io-ai

Package: effect
Module: Record

Record.separate

Partitions a record of Either values into two separate records, one with the Left values and one with the Right values.

Example

import * as assert from "node:assert"
import { Record, Either } from "effect"

assert.deepStrictEqual(
  Record.separate({ a: Either.left("e"), b: Either.right(1) }),
  [{ a: "e" }, { b: 1 }]
)

Signature

declare const separate: <K extends string, A, B>(self: ReadonlyRecord<K, Either<B, A>>) => [Record<ReadonlyRecord.NonLiteralKey<K>, A>, Record<ReadonlyRecord.NonLiteralKey<K>, B>]

Source

Since v2.0.0