import { partitionMap } from "https://deno.land/x/fun@v2.0.0/record.ts";
Given a function that takes an A and a key and returns an Either<J, K> return a function that simultaneously partitions and maps over the values in a ReadonlyRecord. This is the equivalent of first partitioning a ReadonlyRecord, and then using Pair's Bimap over both values in a Pair.
Examples
Example 1
Example 1
import * as R from "./record.ts";
import * as E from "./either.ts";
import { pipe } from "./fn.ts";
const result = pipe(
{ one: 1, two: 2, three: 3 },
R.partitionMap(
n => n > 1
? E.right(`${n} is big enough`)
: E.left(`${n} is small enough`)
),
);
// [
// { two: "2 is big enough", three: "3 is big enough" },
// { one: "1 is small enough" }
// ]
Returns
(ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<I>, ReadonlyRecord<J>>