UNPKG

@payfit/unity-components

Version:

14 lines (13 loc) 487 B
/** * Partitions an array into two arrays based on a predicate function. * More efficient than using filter twice. * @param array - Array to partition * @param predicate - Function to test each element * @returns Tuple of [passing items, failing items] * @example * ```tsx * const [evens, odds] = partition([1, 2, 3, 4], n => n % 2 === 0) * // evens: [2, 4], odds: [1, 3] * ``` */ export declare function partition<T>(array: T[], predicate: (item: T) => boolean): [T[], T[]];