UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

21 lines 1.02 kB
import { Pred } from './_types'; /** * Filter the elements of an array that meet the condition specified in a callback function. * @param array The array to filter. * @param fn the callback function. * @signature * P.filter(array, fn) * @signature * P.filter(fn)(array) * @example * P.filter([1, 2, 3], x => x % 2 === 1) // => [1, 3] * * P.pipe([1, 2, 3], P.filter(x => x % 2 === 1)) // => [1, 3] * @category Array, Pipe */ export declare function partition<T, S extends T>(array: readonly T[], fn: (value: T) => value is S): [S[], Exclude<T, S>[]]; export declare function partition<T>(array: readonly T[], fn: Pred<T, boolean>): T[]; export declare function partition<T, S extends T>(fn: (input: T) => input is S): (array: readonly T[]) => [S[], Exclude<T, S>[]]; export declare function partition<T>(fn: Pred<T, boolean>): (array: readonly T[]) => [T[], T[]]; export declare type PredIndexed<T, K> = (input: T, index: number, array: readonly T[]) => K; //# sourceMappingURL=partition.d.ts.map