UNPKG

sequency

Version:

Functional sequences for processing iterable data in JavaScript

38 lines 1.27 kB
Object.defineProperty(exports, "__esModule", { value: true }); exports.Zip = void 0; var Sequence_1 = require("./Sequence"); var ZipIterator = /** @class */ (function () { function ZipIterator(iterator1, iterator2) { this.iterator1 = iterator1; this.iterator2 = iterator2; } ZipIterator.prototype.next = function (value) { var item1 = this.iterator1.next(); var item2 = this.iterator2.next(); if (item1.done || item2.done) { return { done: true, value: undefined }; } else { return { done: false, value: [item1.value, item2.value] }; } }; return ZipIterator; }()); var Zip = /** @class */ (function () { function Zip() { } /** * Returns a new sequence consisting of pairs built the elements of both sequences * with the same index. The resulting sequence has the length of the shortest input * sequence. All other elements are discarded. * * @param {Sequence<S>} other * @returns {Sequence<[T , S]>} */ Zip.prototype.zip = function (other) { return (0, Sequence_1.createSequence)(new ZipIterator(this.iterator, other.iterator)); }; return Zip; }()); exports.Zip = Zip; //# sourceMappingURL=zip.js.map