@reactivex/ix-es5-esm
Version:
The Interactive Extensions for JavaScript
70 lines (68 loc) • 2.95 kB
JavaScript
import { __asyncGenerator, __await, __extends, __generator } from "tslib";
import { AsyncIterableX } from '../asynciterablex.js';
import { wrapWithAbort } from './withabort.js';
import { throwIfAborted } from '../../aborterror.js';
/** @ignore */
var SkipAsyncIterable = /** @class */ (function (_super) {
__extends(SkipAsyncIterable, _super);
function SkipAsyncIterable(source, count) {
var _this = _super.call(this) || this;
_this._source = source;
_this._count = count;
return _this;
}
SkipAsyncIterable.prototype[Symbol.asyncIterator] = function (signal) {
return __asyncGenerator(this, arguments, function _a() {
var source, it, count, next, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
throwIfAborted(signal);
source = wrapWithAbort(this._source, signal);
it = source[Symbol.asyncIterator]();
count = this._count;
_c.label = 1;
case 1:
_b = count > 0;
if (!_b) return [3 /*break*/, 3];
return [4 /*yield*/, __await(it.next())];
case 2:
_b = !(next = _c.sent()).done;
_c.label = 3;
case 3:
if (!_b) return [3 /*break*/, 4];
count--;
return [3 /*break*/, 1];
case 4:
if (!(count <= 0)) return [3 /*break*/, 9];
_c.label = 5;
case 5: return [4 /*yield*/, __await(it.next())];
case 6:
if (!!(next = _c.sent()).done) return [3 /*break*/, 9];
return [4 /*yield*/, __await(next.value)];
case 7: return [4 /*yield*/, _c.sent()];
case 8:
_c.sent();
return [3 /*break*/, 5];
case 9: return [2 /*return*/];
}
});
});
};
return SkipAsyncIterable;
}(AsyncIterableX));
export { 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.
*/
export function skip(count) {
return function skipOperatorFunction(source) {
return new SkipAsyncIterable(source, count);
};
}
//# sourceMappingURL=skip.js.map