14 lines
323 B
JavaScript
Raw Permalink Normal View History

2026-05-31 13:21:13 +02:00
//#region src/array/partition.ts
function partition(arr, isInTruthy) {
const truthy = [];
const falsy = [];
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
if (isInTruthy(item, i, arr)) truthy.push(item);
else falsy.push(item);
}
return [truthy, falsy];
}
//#endregion
exports.partition = partition;