import { array } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { partitionMap } = array;
Partition and map over a ReadonlyArray in the same loop. Given a predicate A => Either<J, I>, this function passes each element in an array into the predicate. If the predicate returns Right then the inner I is pushed into the first array in a pair. If the predicate returns Left then the inner J is pushed into the second array in a pair.
Examples
Example 1
Example 1
import * as A from "./array.ts";
import * as E from "./either.ts";
import { pipe } from "./fn.ts";
const result = pipe(
A.range(10, 1), // [1, 2, 3, ..., 10]
A.partitionMap(n => n % 2 === 0 ? E.right(n * 100) : E.left(n / 10)),
); // Pair<[200, 400, 600, 800, 1000], [0.1, 0.3, 0.5, 0.7, 0.9]>