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

partition

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

Partition an Iterable into two Iterables based on a predicate. The first contains elements that satisfy the predicate, the second contains elements that don't.

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

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

const evenResult = Array.from(evens); // [2, 4, 6, 8, 10]
const oddResult = Array.from(odds);   // [1, 3, 5, 7, 9]
function partition<A, B extends A>(refinement: (a: A) => a is B): (ua: Iterable<A>) => Pair<Iterable<A>, Iterable<B>>;
function partition<A>(predicate: (a: A) => boolean): (ua: Iterable<A>) => Pair<Iterable<A>, Iterable<A>>;
function partition<A>(predicate: (a: A) => boolean): (ua: Iterable<A>) => Pair<Iterable<A>, Iterable<A>>;
§
partition<A, B extends A>(refinement: (a: A) => a is B): (ua: Iterable<A>) => Pair<Iterable<A>, Iterable<B>>
[src]

Partition an Iterable into two Iterables based on a predicate. The first contains elements that satisfy the predicate, the second contains elements that don't.

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

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

const evenResult = Array.from(evens); // [2, 4, 6, 8, 10]
const oddResult = Array.from(odds);   // [1, 3, 5, 7, 9]

§Type Parameters

§
B extends A
[src]

§Parameters

§
refinement: (a: A) => a is B
[src]

§Return Type

§
(ua: Iterable<A>) => Pair<Iterable<A>, Iterable<B>>
[src]
§
partition<A>(predicate: (a: A) => boolean): (ua: Iterable<A>) => Pair<Iterable<A>, Iterable<A>>
[src]

§Type Parameters

§Parameters

§
predicate: (a: A) => boolean
[src]

§Return Type

§
(ua: Iterable<A>) => Pair<Iterable<A>, Iterable<A>>
[src]
§
partition<A>(predicate: (a: A) => boolean): (ua: Iterable<A>) => Pair<Iterable<A>, Iterable<A>>
[src]

§Type Parameters

§Parameters

§
predicate: (a: A) => boolean
[src]

§Return Type

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