UNPKG

fast-iterable

Version:

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

22 lines (21 loc) 570 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.repeatRecipe = void 0; function* repeat(times, cache) { for (let i = 1; i < times; ++i) { yield* cache; } } function repeatRecipe(map, concat, empty) { return function (n) { if (n >= 1) { const cache = []; return concat.call(map.call(this, (value) => { cache.push(value); return value; }), repeat(n, cache)); } return empty(); }; } exports.repeatRecipe = repeatRecipe;