UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

69 lines (67 loc) 2.54 kB
import { __extends, __generator, __values } from "tslib"; import { IterableX } from '../iterablex.js'; /** @ignore */ var SkipLastIterable = /** @class */ (function (_super) { __extends(SkipLastIterable, _super); function SkipLastIterable(source, count) { var _this = _super.call(this) || this; _this._source = source; _this._count = count; return _this; } SkipLastIterable.prototype[Symbol.iterator] = function () { var q, _a, _b, item, e_1_1; var e_1, _c; return __generator(this, function (_d) { switch (_d.label) { case 0: q = []; _d.label = 1; case 1: _d.trys.push([1, 6, 7, 8]); _a = __values(this._source), _b = _a.next(); _d.label = 2; case 2: if (!!_b.done) return [3 /*break*/, 5]; item = _b.value; q.push(item); if (!(q.length > this._count)) return [3 /*break*/, 4]; return [4 /*yield*/, q.shift()]; case 3: _d.sent(); _d.label = 4; case 4: _b = _a.next(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 8]; case 6: e_1_1 = _d.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 8]; case 7: try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_1) throw e_1.error; } return [7 /*endfinally*/]; case 8: return [2 /*return*/]; } }); }; return SkipLastIterable; }(IterableX)); export { SkipLastIterable }; /** * Bypasses a specified number of elements at the end of an iterable sequence. * * @template TSource The type of the elements in the source sequence. * @param {number} count Number of elements to bypass at the end of the source sequence. * @returns {MonoTypeOperatorFunction<TSource>} An iterable sequence containing the * source sequence elements except for the bypassed ones at the end. */ export function skipLast(count) { return function skipLastOperatorFunction(source) { return new SkipLastIterable(source, count); }; } //# sourceMappingURL=skiplast.js.map