UNPKG

typedash

Version:

modern, type-safe collection of utility functions

25 lines (23 loc) 818 B
//#region src/functions/partition/partition.ts /** * Implementation of all overloads. * @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. */ function partition(array, predicate) { if (array == null) return [[], []]; const equals = []; const notEquals = []; for (const item of array) if (predicate(item)) equals.push(item); else notEquals.push(item); return [equals, notEquals]; } //#endregion Object.defineProperty(exports, 'partition', { enumerable: true, get: function () { return partition; } }); //# sourceMappingURL=partition-Dy-peAI7.cjs.map