partitionMap
import { partitionMap } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/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.
@example
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" }
// ]
function partitionMap<A, I, J>(fai: (a: A, key: string) => Either<J, I>): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<I>, ReadonlyRecord<J>>;
§
partitionMap<A, I, J>(fai: (a: A, key: string) => Either<J, I>): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<I>, ReadonlyRecord<J>>
[src]§Return Type
§
(ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<I>, ReadonlyRecord<J>>
[src]