UNPKG

itertools-ts

Version:

Extended itertools port for TypeScript and JavaScript. Provides a huge set of functions for working with iterable collections (including async ones)

1,013 lines 32.9 kB
"use strict"; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Stream = void 0; var transform_1 = require("./transform"); var single_1 = require("./single"); var multi_1 = require("./multi"); var math_1 = require("./math"); var set_1 = require("./set"); var combinatorics_1 = require("./combinatorics"); var reduce_1 = require("./reduce"); var summary_1 = require("./summary"); var index_1 = require("./index"); /** * Provides fluent interface for working with iterables. */ var Stream = /** @class */ (function () { /** * Stream constructor. * * @param iterable */ function Stream(iterable) { this.data = iterable; } /** * Creates iterable instance with fluent interface. * * @param data */ Stream.of = function (data) { return new Stream((0, transform_1.toIterable)(data)); }; /** * Creates iterable instance with fluent interface from empty iterable source. */ Stream.ofEmpty = function () { return new Stream([]); }; /** * Creates iterable instance with fluent interface from infinite count iterable. * * @param start (optional, default 1) * @param step (optional, default 1) * * @see infinite.count */ Stream.ofCount = function (start, step) { if (start === void 0) { start = 1; } if (step === void 0) { step = 1; } return new Stream(index_1.infinite.count(start, step)); }; /** * Creates iterable instance with fluent interface from infinite collection items repeating. * * @param iterable * * @see infinite.cycle */ Stream.ofCycle = function (iterable) { return new Stream(index_1.infinite.cycle(iterable)); }; /** * Creates iterable instance with fluent interface from infinite item repeating. * * @param item * * @see infinite.repeat */ Stream.ofRepeat = function (item) { return new Stream(index_1.infinite.repeat(item)); }; /** * Iterate stream collection with another iterable collections simultaneously. * * Make an iterator that aggregates items from multiple iterators. * Similar to Python's zip function. * * For uneven lengths, iterations stops when the shortest iterable is exhausted. * * @param iterables * * @see multi.zip */ Stream.prototype.zipWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = multi_1.zip.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Iterate stream collection with another iterable collections simultaneously. * * Make an iterator that aggregates items from multiple iterators. * Similar to Python's zip_longest function. * * Iteration continues until the longest iterable is exhausted. * For uneven lengths, the exhausted iterables will produce `filler` value for the remaining iterations. * * @param filler * @param iterables * * @see multi.zipLongest */ Stream.prototype.zipFilledWith = function (filler) { var iterables = []; for (var _i = 1; _i < arguments.length; _i++) { iterables[_i - 1] = arguments[_i]; } this.data = multi_1.zipFilled.apply(void 0, __spreadArray([filler, this.data], __read(iterables), false)); return this; }; /** * Iterate stream collection with another iterable collections simultaneously. * * Make an iterator that aggregates items from multiple iterators. * Similar to Python's zip_longest function. * * Iteration continues until the longest iterable is exhausted. * For uneven lengths, the exhausted iterables will produce `undefined` for the remaining iterations. * * @param iterables * * @see multi.zipLongest */ Stream.prototype.zipLongestWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = multi_1.zipLongest.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Iterate stream collection with another iterable collections of equal lengths simultaneously. * * Works like multi.zip() method but throws LengthException if lengths not equal, * i.e., at least one iterator ends before the others. * * @param iterables * * @see multi.zipEqual */ Stream.prototype.zipEqualWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = multi_1.zipEqual.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Chain stream collection withs given iterables together into a single iteration. * * Makes a single continuous sequence out of multiple sequences. * * @param iterables * * @see multi.chain */ Stream.prototype.chainWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = multi_1.chain.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Return overlapped chunks of elements from iterable source. * * Chunk size must be at least 1. * * Overlap size must be less than chunk size. * * @param chunkSize * @param overlapSize * @param includeIncompleteTail * * @see single.chunkwiseOverlap */ Stream.prototype.chunkwiseOverlap = function (chunkSize, overlapSize, includeIncompleteTail) { if (includeIncompleteTail === void 0) { includeIncompleteTail = true; } this.data = (0, single_1.chunkwiseOverlap)(this.data, chunkSize, overlapSize, includeIncompleteTail); return this; }; /** * Return chunks of elements from iterable source. * * Chunk size must be at least 1. * * @param chunkSize * * @see single.chunkwise */ Stream.prototype.chunkwise = function (chunkSize) { this.data = (0, single_1.chunkwise)(this.data, chunkSize); return this; }; /** * Compress an iterable source by filtering out data that is not selected. * * Selectors indicate which data. True value selects item. False value filters out data. * * @param selectors * * @see single.compress() */ Stream.prototype.compress = function (selectors) { this.data = (0, single_1.compress)(this.data, selectors); return this; }; /** * Drop elements from the iterable source while the predicate function is true. * * Once the predicate function returns false once, all remaining elements are returned. * * @param predicate * * @see single.dropWhile() */ Stream.prototype.dropWhile = function (predicate) { this.data = (0, single_1.dropWhile)(this.data, predicate); return this; }; /** * Filter out elements from the iterable source only returning elements where there predicate function is true. * * @param predicate * * @see single.filter */ Stream.prototype.filter = function (predicate) { this.data = (0, single_1.filter)(this.data, predicate); return this; }; /** * Enumerates items of given collection. * * @see single.enumerate */ Stream.prototype.enumerate = function () { this.data = (0, single_1.enumerate)(this.data); return this; }; /** * Iterates keys from the collection of key-value pairs. * * @see single.keys */ Stream.prototype.keys = function () { this.data = (0, single_1.keys)(this.data); return this; }; /** * Limit iteration to a max size limit. * * @param count * * @see single.limit */ Stream.prototype.limit = function (count) { this.data = (0, single_1.limit)(this.data, count); return this; }; /** * Map a function onto every element of the stream * * @param mapper * * @see single.map */ Stream.prototype.map = function (mapper) { this.data = (0, single_1.map)(this.data, mapper); return this; }; /** * Returns a new collection formed by applying a given callback function * to each element of the stream, and then flattening the result by one level. * * @param mapper * * @see single.flatMap */ Stream.prototype.flatMap = function (mapper) { this.data = (0, single_1.flatMap)(this.data, mapper); return this; }; /** * Flatten a stream. * * @param dimensions * * @see single.flatten */ Stream.prototype.flatten = function (dimensions) { if (dimensions === void 0) { dimensions = Infinity; } this.data = (0, single_1.flatten)(this.data, dimensions); return this; }; /** * Group stream data by a common data element. * * Iterate pairs of group name and collection of grouped items. * * Collection of grouped items may be an array or an object (depends on presence of `itemKeyFunction` param). * * The `groupKeyFunction` determines the key (or multiple keys) to group elements by. * * The `itemKeyFunction` (optional) determines the key of element in group. * * @param groupKeyFunction * @param itemKeyFunction * * @see single.groupBy */ Stream.prototype.groupBy = function (groupKeyFunction, itemKeyFunction) { this.data = (0, single_1.groupBy)(this.data, groupKeyFunction, itemKeyFunction); return this; }; /** * Return pairs of elements from iterable source. * * Produces empty generator if given collection contains less than 2 elements. * * @see single.pairwise */ Stream.prototype.pairwise = function () { this.data = (0, single_1.pairwise)(this.data); return this; }; /** * Accumulate the running average (mean) over the stream. * * @param initialValue (Optional) If provided, the running average leads off with the initial value. * * @see math.runningAverage */ Stream.prototype.runningAverage = function (initialValue) { this.data = (0, math_1.runningAverage)(this.data, initialValue); return this; }; /** * Accumulate the running difference over the stream. * * @param initialValue (Optional) If provided, the running difference leads off with the initial value. * * @see math.runningDifference */ Stream.prototype.runningDifference = function (initialValue) { this.data = (0, math_1.runningDifference)(this.data, initialValue); return this; }; /** * Accumulate the running max over the stream. * * @param initialValue (Optional) If provided, the running max leads off with the initial value. * * @see math.runningMax */ Stream.prototype.runningMax = function (initialValue) { this.data = (0, math_1.runningMax)(this.data, initialValue); return this; }; /** * Accumulate the running min over the stream. * * @param initialValue (Optional) If provided, the running min leads off with the initial value. * * @see math.runningMin */ Stream.prototype.runningMin = function (initialValue) { this.data = (0, math_1.runningMin)(this.data, initialValue); return this; }; /** * Accumulate the running product over the stream. * * @param initialValue (Optional) If provided, the running product leads off with the initial value. * * @see math.runningProduct */ Stream.prototype.runningProduct = function (initialValue) { this.data = (0, math_1.runningProduct)(this.data, initialValue); return this; }; /** * Accumulate the running total over the stream. * * @param initialValue (Optional) If provided, the running total leads off with the initial value. * * @see math.runningTotal */ Stream.prototype.runningTotal = function (initialValue) { this.data = (0, math_1.runningTotal)(this.data, initialValue); return this; }; /** * Skip n elements in the stream after optional offset. * * @param count * @param offset * * @see single.skip */ Stream.prototype.skip = function (count, offset) { if (offset === void 0) { offset = 0; } this.data = (0, single_1.skip)(this.data, count, offset); return this; }; /** * Extract a slice of the stream. * * @param start * @param count * @param step * * @see single.slice */ Stream.prototype.slice = function (start, count, step) { if (start === void 0) { start = 0; } if (step === void 0) { step = 1; } this.data = (0, single_1.slice)(this.data, start, count, step); return this; }; /** * Return elements from the iterable source as long as the predicate is true. * * If no predicate is provided, the boolean value of the data is used. * * @param predicate * * @see single.takeWhile() */ Stream.prototype.takeWhile = function (predicate) { this.data = (0, single_1.takeWhile)(this.data, predicate); return this; }; /** * Iterates values from the collection of key-value pairs. * * @see single.values */ Stream.prototype.values = function () { this.data = (0, single_1.values)(this.data); return this; }; /** * Sorts the stream. * * If comparator is `undefined`, then elements of the iterable source must be comparable. * * @see single.sort */ Stream.prototype.sort = function (comparator) { this.data = (0, single_1.sort)(this.data, comparator); return this; }; /** * Filter out elements from the iterable source only returning unique elements. * * @param compareBy * * @see set.distinct */ Stream.prototype.distinct = function (compareBy) { this.data = (0, set_1.distinct)(this.data, compareBy); return this; }; /** * Iterates the intersection of iterable source and given iterables. * * Always treats different instances of objects and arrays as unequal. * * @param iterables * * @see set.intersection */ Stream.prototype.intersectionWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = set_1.intersection.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Iterates partial intersection of iterable source and given iterables. * * Always treats different instances of objects and arrays as unequal. * * @param minIntersectionCount * @param iterables * * @see set.partialIntersection */ Stream.prototype.partialIntersectionWith = function (minIntersectionCount) { var iterables = []; for (var _i = 1; _i < arguments.length; _i++) { iterables[_i - 1] = arguments[_i]; } this.data = set_1.partialIntersection.apply(void 0, __spreadArray([minIntersectionCount, this.data], __read(iterables), false)); return this; }; /** * Iterates the symmetric difference of iterable source and given iterables. * * Always treats different instances of objects and arrays as unequal. * * @param iterables * * @see set.symmetricDifference */ Stream.prototype.symmetricDifferenceWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = set_1.symmetricDifference.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Iterates union of iterable source and given iterables. * * Always treats different instances of objects and arrays as unequal. * * @param iterables * * @see set.union */ Stream.prototype.unionWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = set_1.union.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Iterates cartesian product of iterable source and given iterables. * * @param iterables * * @see combinatorics.cartesianProduct */ Stream.prototype.cartesianProductWith = function () { var iterables = []; for (var _i = 0; _i < arguments.length; _i++) { iterables[_i] = arguments[_i]; } this.data = combinatorics_1.cartesianProduct.apply(void 0, __spreadArray([this.data], __read(iterables), false)); return this; }; /** * Iterates all permutations of iterable source. * * @param length * * @see combinatorics.permutations */ Stream.prototype.permutations = function (length) { this.data = (0, combinatorics_1.permutations)(this.data, length); return this; }; /** * Iterates all combinations of iterable source. * * @param length * * @see combinatorics.combinations */ Stream.prototype.combinations = function (length) { this.data = (0, combinatorics_1.combinations)(this.data, length); return this; }; /** * Peek at each element between other Stream operations to do some action without modifying the stream. * * Useful for debugging purposes. * * @param callback */ Stream.prototype.peek = function (callback) { var e_1, _a; var _b = __read((0, transform_1.tee)(this.data, 2), 2), data = _b[0], peekable = _b[1]; this.data = data; try { for (var peekable_1 = __values(peekable), peekable_1_1 = peekable_1.next(); !peekable_1_1.done; peekable_1_1 = peekable_1.next()) { var element = peekable_1_1.value; callback(element); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (peekable_1_1 && !peekable_1_1.done && (_a = peekable_1.return)) _a.call(peekable_1); } finally { if (e_1) throw e_1.error; } } return this; }; /** * Peek at the entire stream between other Stream operations to do some action without modifying the stream. * * Useful for debugging purposes. * * @param callback */ Stream.prototype.peekStream = function (callback) { var _a = __read((0, transform_1.tee)(this.data, 2), 2), data = _a[0], peekable = _a[1]; this.data = data; callback(Stream.of(peekable)); return this; }; /** * Reduces iterable source like `array.reduce()` function. * * @param reducer * @param initialValue * * @see reduce.toValue */ Stream.prototype.toValue = function (reducer, initialValue) { return (0, reduce_1.toValue)(this, reducer, initialValue); }; /** * Reduces iterable source to the mean average of its items. * * Returns `undefined` if iterable source is empty. * * @see reduce.toAverage */ Stream.prototype.toAverage = function () { return (0, reduce_1.toAverage)(this); }; /** * Reduces iterable source to its length. * * @see reduce.toCount */ Stream.prototype.toCount = function () { return (0, reduce_1.toCount)(this); }; /** * Reduces iterable source to its max value. * * Callable param `compareBy` must return comparable value. * * If `compareBy` is not proposed then items of iterable source must be comparable. * * Returns `undefined` if iterable source is empty. * * @param compareBy * * @see reduce.toMax */ Stream.prototype.toMax = function (compareBy) { return (0, reduce_1.toMax)(this, compareBy); }; /** * Reduces iterable source to its min value. * * Callable param `compareBy` must return comparable value. * * If `compareBy` is not proposed then items of iterable source must be comparable. * * Returns `undefined` if iterable source is empty. * * @param compareBy * * @see reduce.toMin */ Stream.prototype.toMin = function (compareBy) { return (0, reduce_1.toMin)(this, compareBy); }; /** * Reduces given collection to array of its upper and lower bounds. * * Callable param `compareBy` must return comparable value. * * If `compareBy` is not proposed then items of given collection must be comparable. * * Returns `[undefined, undefined]` if given collection is empty. * * @param compareBy */ Stream.prototype.toMinMax = function (compareBy) { return (0, reduce_1.toMinMax)(this, compareBy); }; /** * Returns the first element of stream. * * @throws LengthError if stream is empty. * * @see reduce.toFirst */ Stream.prototype.toFirst = function () { return (0, reduce_1.toFirst)(this); }; /** * Returns the first and last elements of stream. * * @throws LengthError if stream is empty. * * @see reduce.toFirstAndLast */ Stream.prototype.toFirstAndLast = function () { return (0, reduce_1.toFirstAndLast)(this); }; /** * Returns the first element of stream. * * @throws LengthError if stream is empty. * * @see reduce.toLast */ Stream.prototype.toLast = function () { return (0, reduce_1.toLast)(this); }; /** * Reduces iterable source to the sum of its items. * * @see reduce.toSum */ Stream.prototype.toSum = function () { return (0, reduce_1.toSum)(this); }; /** * Reduces iterable source to the product of its items. * * Returns `undefined` if iterable source is empty. * * @see reduce.toProduct */ Stream.prototype.toProduct = function () { return (0, reduce_1.toProduct)(this); }; /** * Reduces given collection to its range. * * Returns 0 if given collection is empty. * * @see reduce.toRange */ Stream.prototype.toRange = function () { return (0, reduce_1.toRange)(this); }; /** * Returns true if all elements of stream match the predicate function. * * For empty stream returns true. * * @param predicate * * @see summary.allMatch */ Stream.prototype.allMatch = function (predicate) { return (0, summary_1.allMatch)(this, predicate); }; /** * Returns true if all elements of stream are unique. * * For empty stream returns true. * * Considers different instances of data containers to be different, even if they have the same content. * * @see summary.allUnique */ Stream.prototype.allUnique = function () { return (0, summary_1.allUnique)(this); }; /** * Returns true if any element of stream matches the predicate function. * * For empty stream returns false. * * @param predicate * * @see summary.anyMatch */ Stream.prototype.anyMatch = function (predicate) { return (0, summary_1.anyMatch)(this, predicate); }; /** * Returns true if exactly n items in the iterable are true where the predicate function is true. * * Default predicate if not provided is the boolean value of each data item. * * @param n * @param predicate * * @see summary.exactlyN */ Stream.prototype.exactlyN = function (n, predicate) { return (0, summary_1.exactlyN)(this, n, predicate); }; /** * Returns true if stream is sorted in ascending order; otherwise false. * * Items of stream source must be comparable. * * Also returns true if stream is empty or has only one element. * * @see summary.isSorted */ Stream.prototype.isSorted = function () { return (0, summary_1.isSorted)(this); }; /** * Returns true if stream is sorted in descending order; otherwise false. * * Items of stream source must be comparable. * * Also returns true if stream is empty or has only one element. * * @see summary.isReversed */ Stream.prototype.isReversed = function () { return (0, summary_1.isReversed)(this); }; /** * Returns true if no element of stream matches the predicate function. * * For empty stream returns true. * * @param predicate * * @see summary.noneMatch */ Stream.prototype.noneMatch = function (predicate) { return (0, summary_1.noneMatch)(this, predicate); }; /** * Returns true if stream collection and all given collections are the same. * * For empty collections list returns true. * * @param collections * * @see summary.same */ Stream.prototype.sameWith = function () { var collections = []; for (var _i = 0; _i < arguments.length; _i++) { collections[_i] = arguments[_i]; } return summary_1.same.apply(void 0, __spreadArray([this.data], __read(collections), false)); }; /** * Returns true if stream collection and all given collections have the same lengths. * * For empty collections list returns true. * * @param collections * * @see summary.sameCount */ Stream.prototype.sameCountWith = function () { var collections = []; for (var _i = 0; _i < arguments.length; _i++) { collections[_i] = arguments[_i]; } return summary_1.sameCount.apply(void 0, __spreadArray([this.data], __read(collections), false)); }; /** * Return several independent streams from current stream. * * Once a tee() has been created, the original iterable should not be used anywhere else; * otherwise, the iterable could get advanced without the tee objects being informed. * * This tool may require significant auxiliary storage (depending on how much temporary data needs to be stored). * In general, if one iterator uses most or all of the data before another iterator starts, * it is faster to use toArray() instead of tee(). * * @param count * * @see transform.tee */ Stream.prototype.tee = function (count) { return (0, transform_1.tee)(this.data, count).map(function (iterable) { return new Stream(iterable); }); }; /** * Converts stream to Array. * * @see transform.toArray */ Stream.prototype.toArray = function () { return (0, transform_1.toArray)(this); }; /** * Converts stream to Map. * * Stream collection must contain only key-value pairs as elements. * * @see transform.toMap */ Stream.prototype.toMap = function () { return (0, transform_1.toMap)(this); }; /** * Converts stream to Set. * * @see transform.toSet */ Stream.prototype.toSet = function () { return (0, transform_1.toSet)(this); }; /** * Aggregated iterator. */ Stream.prototype[Symbol.iterator] = function () { var _a, _b, datum, e_2_1; var e_2, _c; return __generator(this, function (_d) { switch (_d.label) { case 0: _d.trys.push([0, 5, 6, 7]); _a = __values(this.data), _b = _a.next(); _d.label = 1; case 1: if (!!_b.done) return [3 /*break*/, 4]; datum = _b.value; return [4 /*yield*/, datum]; case 2: _d.sent(); _d.label = 3; case 3: _b = _a.next(); return [3 /*break*/, 1]; case 4: return [3 /*break*/, 7]; case 5: e_2_1 = _d.sent(); e_2 = { error: e_2_1 }; return [3 /*break*/, 7]; case 6: try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_2) throw e_2.error; } return [7 /*endfinally*/]; case 7: return [2 /*return*/]; } }); }; return Stream; }()); exports.Stream = Stream; //# sourceMappingURL=stream.js.map