UNPKG

@beenotung/tslib

Version:
45 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.polyfillIterable = exports.PolyfillIterable = void 0; class PolyfillIterable { constructor(iterable) { this.iterable = iterable; } [Symbol.iterator]() { return this.iterable[Symbol.iterator](); } map(map) { const self = this; return new PolyfillIterable({ *[Symbol.iterator]() { for (const x of self) { yield map(x); } }, }); } filter(filter) { const self = this; return new PolyfillIterable({ *[Symbol.iterator]() { for (const x of self) { if (filter(x)) { yield x; } } }, }); } toArray() { return Array.from(this.iterable); } static from(iterable) { return new PolyfillIterable(iterable); } } exports.PolyfillIterable = PolyfillIterable; function polyfillIterable(iterable) { return PolyfillIterable.from(iterable); } exports.polyfillIterable = polyfillIterable; //# sourceMappingURL=polyfill-iterable.js.map