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/record.ts";

Given a refinement or predicate, return a function that splits a ReadonlyRecord into a Pair of ReadonlyRecords, with the first record containing the values for which the predicate/refinement returned true and the second record containing the values for which the predicate/refinement returned false.

@example
import * as R from "./record.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  { one: 1, two: 2, three: 3 },
  R.partition(n => n > 1),
); // [{ two: 2, three: 3 }, { one: 1 }]
function partition<A, I extends A>(refinement: (a: A, key: string) => a is I): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<I>, ReadonlyRecord<A>>;
function partition<A>(predicate: (a: A, key: string) => boolean): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<A>, ReadonlyRecord<A>>;
function partition<A>(predicate: (a: A, key: string) => boolean): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<A>, ReadonlyRecord<A>>;
§
partition<A, I extends A>(refinement: (a: A, key: string) => a is I): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<I>, ReadonlyRecord<A>>
[src]

Given a refinement or predicate, return a function that splits a ReadonlyRecord into a Pair of ReadonlyRecords, with the first record containing the values for which the predicate/refinement returned true and the second record containing the values for which the predicate/refinement returned false.

@example
import * as R from "./record.ts";
import { pipe } from "./fn.ts";

const result = pipe(
  { one: 1, two: 2, three: 3 },
  R.partition(n => n > 1),
); // [{ two: 2, three: 3 }, { one: 1 }]

§Type Parameters

§
I extends A
[src]

§Parameters

§
refinement: (a: A, key: string) => a is I
[src]
§
partition<A>(predicate: (a: A, key: string) => boolean): (ua: ReadonlyRecord<A>) => Pair<ReadonlyRecord<A>, ReadonlyRecord<A>>
[src]

§Type Parameters

§Parameters

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

§Type Parameters

§Parameters

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