Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

partitionMap

import { partitionMap } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/iterable.ts";

Partition an Iterable into two Iterables based on an Either result. Right values go to the first Iterable, Left values to the second.

@example
import * as I from "./iterable.ts";
import * as E from "./either.ts";

const numbers = I.wrap(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
const [evens, odds] = I.partitionMap((n: number) =>
  n % 2 === 0 ? E.right(n) : E.left(n)
)(numbers);

const evenResult = Array.from(evens); // [2, 4, 6, 8, 10]
const oddResult = Array.from(odds);   // [1, 3, 5, 7, 9]
function partitionMap<A, I, J>(predicate: (a: A) => Either<J, I>): (ua: Iterable<A>) => Pair<Iterable<I>, Iterable<J>>;
§
partitionMap<A, I, J>(predicate: (a: A) => Either<J, I>): (ua: Iterable<A>) => Pair<Iterable<I>, Iterable<J>>
[src]

§Type Parameters

§Parameters

§
predicate: (a: A) => Either<J, I>
[src]

§Return Type

§
(ua: Iterable<A>) => Pair<Iterable<I>, Iterable<J>>
[src]