@codibre/fluent-iterable
Version:
Provides LINQ-like fluent api operations for iterables and async iterables (ES2018+).
21 lines (20 loc) • 879 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unwindRecipe = unwindRecipe;
function unwindRecipe({ resolver, flatten, map, combineJoin, toObject, symbols, }) {
return function (...keys) {
return flatten.call(this, (value) => {
const it = map.call(keys, (x) => {
const current = value[x];
return symbols.some((symbol) => typeof current !== 'string' &&
typeof current[symbol] === 'function')
? map.call(current, (v) => [x, v])
: [[x, current]];
});
return resolver(combineJoin.call(it), (it2) => map.call(it2, (unwindedValues) => resolver(toObject.call(unwindedValues, (u) => u[0], (u) => u[1]), (unwinded) => ({
unwinded,
value,
}))));
});
};
}