@codibre/fluent-iterable
Version:
Provides LINQ-like fluent api operations for iterables and async iterables (ES2018+).
32 lines (31 loc) • 950 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mountSpecial = mountSpecial;
const utils_1 = require("../utils");
function mountSpecial({ group, groupAsync, partition, next }, wrapper, asyncWrapper) {
const result = {};
const groups = [
[group, 'group', wrapper],
[groupAsync, 'groupAsync', asyncWrapper],
];
groups.forEach(([g, name, w]) => {
if (g) {
result[name] = function (...args) {
return w(g.call(this, ...args)).map(utils_1.fluentGroup);
};
}
});
if (partition) {
result.partition = function (...args) {
return wrapper(partition.call(this, ...args)).map((part) => {
return wrapper(part);
});
};
}
if (next) {
result.next = function (...args) {
return next.call(wrapper(this), ...args);
};
}
return result;
}