pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
17 lines (16 loc) • 489 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.partition = void 0;
function partition(by, coll) {
if (arguments.length === 1)
return (_coll) => partition(by, _coll);
const result = { t: [], f: [] };
(coll !== null && coll !== void 0 ? coll : []).forEach((value) => {
if (by(value))
result.t.push(value);
else
result.f.push(value);
});
return result;
}
exports.partition = partition;