es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
21 lines (17 loc) • 448 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
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];
}
exports.partition = partition;