UNPKG

typedash

Version:

modern, type-safe collection of utility functions

19 lines (16 loc) 1.14 kB
import { M as Maybe } from '../Maybe-D6dwMjD9.cjs'; /** * Partitions an array into two arrays based on a predicate function. * @param array The input array to partition. * @param predicate A function that takes an array item and returns a boolean indicating whether the item should be included in the "equals" array or the "notEquals" array. * @returns A tuple containing two arrays: the "equals" array and the "notEquals" array. */ declare function partition<T, S extends T>(array: Maybe<readonly T[]>, predicate: (item: T) => item is S): readonly [equals: S[], notEquals: Array<Exclude<T, S>>]; /** * Partitions an array into two arrays based on a predicate function. * @param array The input array to partition. * @param predicate A function that takes an array item and returns a boolean indicating whether the item should be included in the "equals" array or the "notEquals" array. * @returns A tuple containing two arrays: the "equals" array and the "notEquals" array. */ declare function partition<T>(array: Maybe<readonly T[]>, predicate: (item: T) => boolean): readonly [equals: T[], notEquals: T[]]; export { partition };