UNPKG

fast-iterable

Version:

Provides LINQ-like fluent api operations for iterables and async iterables (ES2018+).

31 lines (30 loc) 934 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mountSpecial = void 0; 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); }; } }); 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; } exports.mountSpecial = mountSpecial;