UNPKG

@reactivex/ix-es2015-cjs

Version:

The Interactive Extensions for JavaScript

50 lines (48 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.skip = exports.SkipAsyncIterable = void 0; const tslib_1 = require("tslib"); const asynciterablex_js_1 = require("../asynciterablex.js"); const withabort_js_1 = require("./withabort.js"); const aborterror_js_1 = require("../../aborterror.js"); /** @ignore */ class SkipAsyncIterable extends asynciterablex_js_1.AsyncIterableX { constructor(source, count) { super(); this._source = source; this._count = count; } [Symbol.asyncIterator](signal) { return tslib_1.__asyncGenerator(this, arguments, function* _a() { (0, aborterror_js_1.throwIfAborted)(signal); const source = (0, withabort_js_1.wrapWithAbort)(this._source, signal); const it = source[Symbol.asyncIterator](); let count = this._count; let next; while (count > 0 && !(next = yield tslib_1.__await(it.next())).done) { count--; } if (count <= 0) { while (!(next = yield tslib_1.__await(it.next())).done) { yield yield tslib_1.__await(next.value); } } }); } } exports.SkipAsyncIterable = SkipAsyncIterable; /** * Bypasses a specified number of elements in an async-iterable sequence and then returns the remaining elements. * * @template TSource The type of the elements in the source sequence. * @param {number} count The number of elements to skip before returning the remaining elements. * @returns {MonoTypeOperatorAsyncFunction<TSource>} An async-iterable sequence that contains the elements that * occur after the specified index in the input sequence. */ function skip(count) { return function skipOperatorFunction(source) { return new SkipAsyncIterable(source, count); }; } exports.skip = skip; //# sourceMappingURL=skip.js.map