@reactivex/ix-es5-esm
Version:
The Interactive Extensions for JavaScript
71 lines (69 loc) • 2.59 kB
JavaScript
import { __extends, __generator, __values } from "tslib";
import { IterableX } from '../iterablex.js';
/** @ignore */
var PairwiseIterable = /** @class */ (function (_super) {
__extends(PairwiseIterable, _super);
function PairwiseIterable(source) {
var _this = _super.call(this) || this;
_this._source = source;
return _this;
}
PairwiseIterable.prototype[Symbol.iterator] = function () {
var value, hasValue, _a, _b, item, e_1_1;
var e_1, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
hasValue = false;
_d.label = 1;
case 1:
_d.trys.push([1, 8, 9, 10]);
_a = __values(this._source), _b = _a.next();
_d.label = 2;
case 2:
if (!!_b.done) return [3 /*break*/, 7];
item = _b.value;
if (!!hasValue) return [3 /*break*/, 3];
hasValue = true;
return [3 /*break*/, 5];
case 3: return [4 /*yield*/, [value, item]];
case 4:
_d.sent();
_d.label = 5;
case 5:
value = item;
_d.label = 6;
case 6:
_b = _a.next();
return [3 /*break*/, 2];
case 7: return [3 /*break*/, 10];
case 8:
e_1_1 = _d.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 10];
case 9:
try {
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
}
finally { if (e_1) throw e_1.error; }
return [7 /*endfinally*/];
case 10: return [2 /*return*/];
}
});
};
return PairwiseIterable;
}(IterableX));
export { PairwiseIterable };
/**
* Returns a sequence of each element in the input sequence and its predecessor, with the exception of the
* first element which is only returned as the predecessor of the second element.
*
* @template TSource The type of the elements in the source sequence.
* @returns {OperatorFunction<TSource, TSource[]>} The result sequence.
*/
export function pairwise() {
return function pairwiseOperatorFunction(source) {
return new PairwiseIterable(source);
};
}
//# sourceMappingURL=pairwise.js.map