From 0f83ba907c24d6e325431c7b40358b7d9dd1468c Mon Sep 17 00:00:00 2001 From: Frederik Tilkin Date: Tue, 27 Aug 2024 17:23:00 +0200 Subject: [PATCH] Version 0.4.9 Changes: --- .../cjs/operators/general/branchAndMerge.d.ts | 2 +- dist/cjs/operators/general/distribute.d.ts | 88 ++++++++ dist/cjs/operators/general/distribute.js | 208 ++++++++++++++++++ dist/cjs/operators/general/distribute.js.map | 1 + dist/cjs/operators/general/filter.js.map | 2 +- dist/cjs/operators/general/identity.js.map | 2 +- dist/cjs/operators/general/index.d.ts | 1 + dist/cjs/operators/general/index.js | 1 + dist/cjs/operators/general/index.js.map | 2 +- dist/cjs/operators/general/tap.d.ts | 2 +- dist/cjs/operators/general/tap.js.map | 2 +- dist/itr8.min.js | 12 +- dist/itr8.min.js.map | 8 +- dist/operators/general/branchAndMerge.d.ts | 2 +- dist/operators/general/distribute.d.ts | 88 ++++++++ dist/operators/general/distribute.js | 205 +++++++++++++++++ dist/operators/general/distribute.js.map | 1 + dist/operators/general/filter.js.map | 2 +- dist/operators/general/identity.js.map | 2 +- dist/operators/general/index.d.ts | 1 + dist/operators/general/index.js | 1 + dist/operators/general/index.js.map | 2 +- dist/operators/general/tap.d.ts | 2 +- dist/operators/general/tap.js.map | 2 +- docs/assets/search.js | 2 +- docs/functions/interface.forEach.html | 2 +- docs/functions/interface.itr8FromArray.html | 2 +- .../interface.itr8FromArrayAsync.html | 2 +- .../interface.itr8FromImpureFunction.html | 2 +- .../functions/interface.itr8FromIterable.html | 2 +- .../interface.itr8FromSingleValue.html | 2 +- .../interface.itr8FromSingleValueAsync.html | 2 +- docs/functions/interface.itr8FromString.html | 2 +- .../interface.itr8FromStringAsync.html | 2 +- docs/functions/interface.itr8Interval.html | 2 +- docs/functions/interface.itr8Pushable.html | 2 +- docs/functions/interface.itr8Range.html | 2 +- docs/functions/interface.itr8RangeAsync.html | 2 +- docs/functions/interface.itr8ToArray.html | 2 +- .../interface.itr8ToMultiIterable.html | 2 +- docs/functions/interface.itr8ToObject.html | 2 +- docs/functions/interface.itr8ToString.html | 2 +- docs/functions/operators.average.html | 3 +- docs/functions/operators.branchAndMerge.html | 17 +- docs/functions/operators.debounce.html | 3 +- docs/functions/operators.dedup.html | 3 +- docs/functions/operators.delay.html | 3 +- docs/functions/operators.distribute.html | 141 ++++++++++++ docs/functions/operators.every.html | 3 +- docs/functions/operators.filter.html | 3 +- docs/functions/operators.flatten.html | 3 +- docs/functions/operators.groupPer.html | 3 +- docs/functions/operators.identity.html | 3 +- docs/functions/operators.intersperse.html | 3 +- docs/functions/operators.lineByLine.html | 3 +- docs/functions/operators.map.html | 3 +- docs/functions/operators.max.html | 3 +- docs/functions/operators.min.html | 3 +- docs/functions/operators.mostRecent.html | 3 +- docs/functions/operators.parallel.html | 11 +- docs/functions/operators.peek.html | 3 +- docs/functions/operators.percentile.html | 3 +- docs/functions/operators.powerMap.html | 3 +- docs/functions/operators.prefetch.html | 3 +- docs/functions/operators.reduce.html | 3 +- docs/functions/operators.repeat.html | 3 +- docs/functions/operators.repeatEach.html | 3 +- docs/functions/operators.runningAverage.html | 3 +- .../operators.runningPercentile.html | 3 +- docs/functions/operators.runningReduce.html | 3 +- docs/functions/operators.runningTotal.html | 3 +- docs/functions/operators.skip.html | 3 +- docs/functions/operators.skipWhile.html | 3 +- docs/functions/operators.some.html | 3 +- docs/functions/operators.sort.html | 3 +- docs/functions/operators.split.html | 3 +- docs/functions/operators.stringToChar.html | 3 +- docs/functions/operators.take.html | 3 +- docs/functions/operators.takeWhile.html | 3 +- docs/functions/operators.tap.html | 11 +- docs/functions/operators.throttle.html | 3 +- docs/functions/operators.total.html | 3 +- docs/functions/operators.uniq.html | 3 +- docs/functions/operators.uniqBy.html | 3 +- docs/functions/operators.zip.html | 3 +- docs/functions/peer.itr8FromObservable.html | 2 +- docs/functions/peer.itr8FromStdin.html | 2 +- docs/functions/peer.itr8FromStream.html | 2 +- docs/functions/peer.itr8ToObservable.html | 2 +- docs/functions/peer.itr8ToReadableStream.html | 2 +- docs/functions/peer.parseJson.html | 2 +- docs/functions/util.compose.html | 22 +- docs/functions/util.doAfter.html | 2 +- docs/functions/util.doAfterFactory.html | 2 +- docs/functions/util.forLoop.html | 2 +- docs/functions/util.isPromise.html | 2 +- docs/functions/util.pipe.html | 22 +- docs/functions/util.thenable.html | 2 +- docs/functions/util.thenableFactory.html | 2 +- docs/modules/index.html | 6 +- docs/modules/interface.html | 2 +- docs/modules/operators.html | 10 +- docs/modules/peer.html | 2 +- docs/modules/util.html | 2 +- docs/pages/CHANGELOG.html | 32 ++- docs/sitemap.txt | 137 ++++++------ docs/types/index.TNextFnResult.html | 3 +- docs/types/index.TPushable.html | 3 +- docs/types/index.TThenable.html | 3 +- .../index.TTransIteratorSyncOrAsync.html | 3 +- docs/variables/util.AsyncFunction.html | 2 +- package-lock.json | 4 +- package.json | 2 +- 113 files changed, 1034 insertions(+), 217 deletions(-) create mode 100644 dist/cjs/operators/general/distribute.d.ts create mode 100644 dist/cjs/operators/general/distribute.js create mode 100644 dist/cjs/operators/general/distribute.js.map create mode 100644 dist/operators/general/distribute.d.ts create mode 100644 dist/operators/general/distribute.js create mode 100644 dist/operators/general/distribute.js.map create mode 100644 docs/functions/operators.distribute.html diff --git a/dist/cjs/operators/general/branchAndMerge.d.ts b/dist/cjs/operators/general/branchAndMerge.d.ts index 1ab54cf..5230f1a 100644 --- a/dist/cjs/operators/general/branchAndMerge.d.ts +++ b/dist/cjs/operators/general/branchAndMerge.d.ts @@ -55,7 +55,7 @@ import { TTransIteratorSyncOrAsync } from "../../types.js"; * @param {...(it:Iterator | AsyncIterator)=>Iterator | AsyncIterator} moreTransIts * @returns * - * @category operators/async + * @category operators/general */ declare function branchAndMerge(transIt1: TTransIteratorSyncOrAsync): TTransIteratorSyncOrAsync; declare function branchAndMerge(transIt1: TTransIteratorSyncOrAsync, transIt2: TTransIteratorSyncOrAsync): TTransIteratorSyncOrAsync; diff --git a/dist/cjs/operators/general/distribute.d.ts b/dist/cjs/operators/general/distribute.d.ts new file mode 100644 index 0000000..856d874 --- /dev/null +++ b/dist/cjs/operators/general/distribute.d.ts @@ -0,0 +1,88 @@ +import { TTransIteratorSyncOrAsync } from "../../types.js"; +/** + * This operator should make it easy to distribute different categories on the input iterator, + * to multiple child iterators for further processing per category. + * The child iterator depends on the 'category' that is determined by the first element + * of the tuple. + * + * Imagine things like: I need to calculate the averages 'per schoolyear'. + * That would mean, categorize per schoolyear, and then calculate the average + * of the inner iterators by using a map after distribute. + * + * If you are not going to use all output iterators, make sure to filter out + * the categories you don't need before using distribute, because otherwise an unused + * buffer will be held needlessly in memory. + * + * The category is compared using simple equality checks, so strings and numbers are an easy fit. + * If you need more complex categories (like an array), make sure to return the same instance + * as the category. (Maybe we should create a 'categorize' or 'groupBy' operator that + * can help with dealing with more complex categories?) + * + * Questions: + * - Imagine you use it to categorize http requests (for example by sender ip/port), + * how do we 'close' a channel after a while so we can avoid the memory to keep growing? + * I mean, after some time you'll assume that the same 'sender' has done, and the output terator's + * next() call should return { done: true }. Would that be a setting, + * like the (unfinished) 'abandoned timeout' in the 'multiIterable' operator? + * - It could make sense to create a version that can handle multiple categories per value. + * Like for instance: divisible by 2, divisible by 3, divisible by 5, etc. + * where some values can be in multiple categories. + * This could also be done by making a categorize operator that can produce multiple tuples + * for each input, which would keep this operator simple. + * + * ``` + * ┌───────────────────────────────────────────────────────────┐ + * │input iterator with tuples of the form [ category, value ] | + * └──────┬────────────────────────────────────────────────────┘ + * │ + * ┌──────▼───────────────────────┐ + * │ output iterator of iterators │ + * │ (1 next() for each category) │ + * └──────────────────────────────┘ + * ├─────────────────────────────┐────────────────────── ... + * │ │ + * ┌────▼─────────────────────┐ ┌────▼─────────────────────┐ + * │ [ category 1, iterator ] │ │ [ category 2, iterator ] │ + * └────┬─────────────────────┘ └──────────────────────────┘ + * │ + * │ + * ┌──────▼──────────────────────────┐ + * │ forEach([ cetegory, iterator ]) │ + * └─────────────────────────────────┘ + * | + * ↳ pipe( iterator, ) + * ``` + * + * @example + * ```typescript + * await pipe( + * itr8ange(1, 1000), + * map( (v) => [ v % 2 === 0 ? 'even' : 'odd', v ] as [string, number] ), // add the category to the value + * // adding the category first allows us to easily filter out categories we don't need + * distribute(), + * map(([category, iterator]) => ({ + * category, + * values: pipe( + * iterator, + * take(2), + * toArray, + * ), + * })), + * itr8ToArray, + * ) + * // => [ + * // { category: 'odd', values: [ 1, 3 ] }, + * // { category: 'even', values: [ 2, 4 ] }, + * // ] + * ``` + * + * @category operators/general + */ +declare function distribute(): TTransIteratorSyncOrAsync<[ + C, + T +], [ + C, + IterableIterator | AsyncIterableIterator +]>; +export { distribute }; diff --git a/dist/cjs/operators/general/distribute.js b/dist/cjs/operators/general/distribute.js new file mode 100644 index 0000000..f968324 --- /dev/null +++ b/dist/cjs/operators/general/distribute.js @@ -0,0 +1,208 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.distribute = void 0; +const index_js_1 = require("../../interface/index.js"); +const index_js_2 = require("../../util/index.js"); +/** + * This operator should make it easy to distribute different categories on the input iterator, + * to multiple child iterators for further processing per category. + * The child iterator depends on the 'category' that is determined by the first element + * of the tuple. + * + * Imagine things like: I need to calculate the averages 'per schoolyear'. + * That would mean, categorize per schoolyear, and then calculate the average + * of the inner iterators by using a map after distribute. + * + * If you are not going to use all output iterators, make sure to filter out + * the categories you don't need before using distribute, because otherwise an unused + * buffer will be held needlessly in memory. + * + * The category is compared using simple equality checks, so strings and numbers are an easy fit. + * If you need more complex categories (like an array), make sure to return the same instance + * as the category. (Maybe we should create a 'categorize' or 'groupBy' operator that + * can help with dealing with more complex categories?) + * + * Questions: + * - Imagine you use it to categorize http requests (for example by sender ip/port), + * how do we 'close' a channel after a while so we can avoid the memory to keep growing? + * I mean, after some time you'll assume that the same 'sender' has done, and the output terator's + * next() call should return { done: true }. Would that be a setting, + * like the (unfinished) 'abandoned timeout' in the 'multiIterable' operator? + * - It could make sense to create a version that can handle multiple categories per value. + * Like for instance: divisible by 2, divisible by 3, divisible by 5, etc. + * where some values can be in multiple categories. + * This could also be done by making a categorize operator that can produce multiple tuples + * for each input, which would keep this operator simple. + * + * ``` + * ┌───────────────────────────────────────────────────────────┐ + * │input iterator with tuples of the form [ category, value ] | + * └──────┬────────────────────────────────────────────────────┘ + * │ + * ┌──────▼───────────────────────┐ + * │ output iterator of iterators │ + * │ (1 next() for each category) │ + * └──────────────────────────────┘ + * ├─────────────────────────────┐────────────────────── ... + * │ │ + * ┌────▼─────────────────────┐ ┌────▼─────────────────────┐ + * │ [ category 1, iterator ] │ │ [ category 2, iterator ] │ + * └────┬─────────────────────┘ └──────────────────────────┘ + * │ + * │ + * ┌──────▼──────────────────────────┐ + * │ forEach([ cetegory, iterator ]) │ + * └─────────────────────────────────┘ + * | + * ↳ pipe( iterator, ) + * ``` + * + * @example + * ```typescript + * await pipe( + * itr8ange(1, 1000), + * map( (v) => [ v % 2 === 0 ? 'even' : 'odd', v ] as [string, number] ), // add the category to the value + * // adding the category first allows us to easily filter out categories we don't need + * distribute(), + * map(([category, iterator]) => ({ + * category, + * values: pipe( + * iterator, + * take(2), + * toArray, + * ), + * })), + * itr8ToArray, + * ) + * // => [ + * // { category: 'odd', values: [ 1, 3 ] }, + * // { category: 'even', values: [ 2, 4 ] }, + * // ] + * ``` + * + * @category operators/general + */ +function distribute() { + const bufferMap = new Map(); + // we need an ordered list in order to respond to next calls on the outer iterator + const categoriesArray = []; + let categoriesIndex = -1; + let distributionDone = false; + const addToCategory = (category, value) => { + if (bufferMap.has(category)) { + bufferMap.get(category).push(value); + } + else { + bufferMap.set(category, [value]); + categoriesArray.push(category); + } + }; + /** + * It will return the first value from the buffer of the given category, + * and update the buffer at the same time. + * + * @param category + * @returns the value from the buffer, or Symbol['categoryEmpty'] + */ + const getFromCategory = (category) => { + if (bufferMap.has(category)) { + const buffer = bufferMap.get(category); + if (buffer && buffer.length > 0) { + return buffer.shift(); + } + } + return Symbol["categoryEmpty"]; + }; + /** + * The function that will categorize the input iterator's values and update the internal state. + * @param itResult + */ + const distributeIn = (itResult) => { + if (itResult.done) { + distributionDone = true; + } + else { + addToCategory(itResult.value[0], itResult.value[1]); + } + }; + return (inputIterator) => { + function* generateInnerIterableSync(category) { + if (!bufferMap.has(category)) { + throw new Error(`Category ${category} not found in bufferMap`); + } + let innerIterableDone = false; + while (!innerIterableDone) { + const valueToYieldMaybe = getFromCategory(category); + if (valueToYieldMaybe !== Symbol["categoryEmpty"]) { + yield valueToYieldMaybe; + } + else if (distributionDone) { + innerIterableDone = true; + } + else { + distributeIn(inputIterator.next()); + } + } + } + /** + * This function is a generator that will categorize the input iterator's values + * and returns [category, iterator] tuples. + */ + function* generateOuterIterableSync(firstNext) { + for (let nextIn = firstNext; !nextIn.done; nextIn = inputIterator.next()) { + distributeIn(nextIn); + while (categoriesIndex < categoriesArray.length - 1) { + categoriesIndex += 1; + const category = categoriesArray[categoriesIndex]; + yield [ + category, + (0, index_js_1.itr8FromIterable)(generateInnerIterableSync(category)), + ]; + } + } + distributionDone = true; + } + async function* generateInnerIterableAsync(category) { + if (!bufferMap.has(category)) { + throw new Error(`Category ${category} not found in bufferMap`); + } + let innerIterableDone = false; + while (!innerIterableDone) { + const valueToYieldMaybe = getFromCategory(category); + if (valueToYieldMaybe !== Symbol["categoryEmpty"]) { + yield valueToYieldMaybe; + } + else if (distributionDone) { + innerIterableDone = true; + } + else { + distributeIn((await inputIterator.next())); + } + } + } + /** + * This function is a generator that will categorize the input iterator's values + * and returns [category, iterator] tuples. + */ + async function* generateOuterIterableAsync(firstNext) { + for (let nextIn = await firstNext; !nextIn.done; nextIn = await inputIterator.next()) { + distributeIn(nextIn); + while (categoriesIndex < categoriesArray.length - 1) { + categoriesIndex += 1; + const category = categoriesArray[categoriesIndex]; + yield [ + category, + (0, index_js_1.itr8FromIterable)(generateInnerIterableAsync(category)), + ]; + } + } + distributionDone = true; + } + const firstNext = inputIterator.next(); + return (0, index_js_2.isPromise)(firstNext) + ? generateOuterIterableAsync(firstNext) + : generateOuterIterableSync(firstNext); + }; +} +exports.distribute = distribute; +//# sourceMappingURL=distribute.js.map \ No newline at end of file diff --git a/dist/cjs/operators/general/distribute.js.map b/dist/cjs/operators/general/distribute.js.map new file mode 100644 index 0000000..2c166ad --- /dev/null +++ b/dist/cjs/operators/general/distribute.js.map @@ -0,0 +1 @@ +{"version":3,"file":"distribute.js","sourceRoot":"","sources":["../../../../src/operators/general/distribute.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAE5D,kDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,SAAS,UAAU;IAIjB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAe,CAAC;IACzC,kFAAkF;IAClF,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,IAAI,eAAe,GAAG,CAAC,CAAC,CAAC;IACzB,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAE7B,MAAM,aAAa,GAAG,CAAC,QAAW,EAAE,KAAQ,EAAE,EAAE;QAC9C,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC3B,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACtC;aAAM;YACL,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;YACjC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAChC;IACH,CAAC,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,eAAe,GAAG,CAAC,QAAW,EAAE,EAAE;QACtC,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACvC,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gB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BAClD,MAAM;wBACJ,QAAQ;wBACR,IAAA,2BAAgB,EAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC;qBACtB,CAAC;iBACpC;aACF;YACD,gBAAgB,GAAG,IAAI,CAAC;QAC1B,CAAC;QAED,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;QACvC,OAAO,IAAA,oBAAS,EAAC,SAAS,CAAC;YACzB,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC;YACvC,CAAC,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC;AAEQ,gCAAU"} \ No newline at end of file diff --git a/dist/cjs/operators/general/filter.js.map b/dist/cjs/operators/general/filter.js.map index 7d27aa0..c76e268 100644 --- a/dist/cjs/operators/general/filter.js.map +++ b/dist/cjs/operators/general/filter.js.map @@ -1 +1 @@ -{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../src/operators/general/filter.ts"],"names":[],"mappings":";;;AACA,kDAA0D;AAC1D,+CAAyC;AAEzC;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,CAAM,QAAgD,EAAE,EAAE;IACvE,8EAA8E;IAC9E,IAAI,sCAAsC,GAAG,UAC3C,mBAA+C,EAC/C,MAAM;QAEN,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAgC,EAAE,EAAE;YAC7D,IAAI,cAAc,EAAE;gBAClB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAW,CAAC;aACtD;iBAAM;gBACL,OAAO,EAAE,IAAI,EAAE,KAAK,EAAW,CAAC;aACjC;QACH,CAAC,CAAC;QAEF,sCAAsC,GAAG,IAAA,oBAAS,EAAC,mBAAmB,CAAC;YACrE,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CACvB,aAAkC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAClD,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAClB;YACL,CAAC,CAAC,CAAC,CAAC;QACN,OAAO,sCAAsC,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC;IAEF,OAAO,IAAA,sBAAQ,EACb,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACjB,IAAI,MAAM,CAAC,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAEvC,OAAO,sCAAsC,CAC3C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EACtB,MAAM,CACP,CAAC;QAEF,qDAAqD;QACrD,6DAA6D;QAC7D,6DAA6D;QAC7D,4BAA4B;QAC5B,UAAU;QAEV,yCAAyC;QACzC,2BAA2B;QAC3B,0BAA0B;QAC1B,qEAAqE;QACrE,8BAA8B;QAC9B,UAAU;QACV,WAAW;QACX,6DAA6D;QAC7D,4BAA4B;QAC5B,IAAI;IACN,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AACJ,CAAC,CAAC;AAEO,wBAAM"} \ No newline at end of file +{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../src/operators/general/filter.ts"],"names":[],"mappings":";;;AACA,kDAAgD;AAChD,+CAAyC;AAEzC;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,CAAM,QAAgD,EAAE,EAAE;IACvE,8EAA8E;IAC9E,IAAI,sCAAsC,GAAG,UAC3C,mBAA+C,EAC/C,MAAM;QAEN,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAgC,EAAE,EAAE;YAC7D,IAAI,cAAc,EAAE;gBAClB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAW,CAAC;aACtD;iBAAM;gBACL,OAAO,EAAE,IAAI,EAAE,KAAK,EAAW,CAAC;aACjC;QACH,CAAC,CAAC;QAEF,sCAAsC,GAAG,IAAA,oBAAS,EAAC,mBAAmB,CAAC;YACrE,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CACvB,aAAkC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAClD,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAClB;YACL,CAAC,CAAC,CAAC,CAAC;QACN,OAAO,sCAAsC,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC;IAEF,OAAO,IAAA,sBAAQ,EACb,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACjB,IAAI,MAAM,CAAC,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAEvC,OAAO,sCAAsC,CAC3C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EACtB,MAAM,CACP,CAAC;QAEF,qDAAqD;QACrD,6DAA6D;QAC7D,6DAA6D;QAC7D,4BAA4B;QAC5B,UAAU;QAEV,yCAAyC;QACzC,2BAA2B;QAC3B,0BAA0B;QAC1B,qEAAqE;QACrE,8BAA8B;QAC9B,UAAU;QACV,WAAW;QACX,6DAA6D;QAC7D,4BAA4B;QAC5B,IAAI;IACN,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AACJ,CAAC,CAAC;AAEO,wBAAM"} \ No newline at end of file diff --git a/dist/cjs/operators/general/identity.js.map b/dist/cjs/operators/general/identity.js.map index eef741b..cb3adc2 100644 --- a/dist/cjs/operators/general/identity.js.map +++ b/dist/cjs/operators/general/identity.js.map @@ -1 +1 @@ -{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../../src/operators/general/identity.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ;IACf,OAAO,UACL,EAAkC;QAElC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YAC5B,OAAO,EAA8B,CAAC;SACvC;aAAM,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO,EAAyB,CAAC;SAClC;aAAM;YACL,MAAM,KAAK,GAAwB;gBACjC,IAAI,EAAE,EAAE,CAAC,IAA+B;gBACxC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK;aAC/B,CAAC;YACF,OAAO,KAAK,CAAC;SACd;IACH,CAAC,CAAC;AACJ,CAAC;AAEQ,4BAAQ"} \ No newline at end of file +{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../../src/operators/general/identity.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ;IACf,OAAO,UACL,EAAkC;QAElC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YAC5B,OAAO,EAA8B,CAAC;SACvC;aAAM,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO,EAAyB,CAAC;SAClC;aAAM;YACL,MAAM,KAAK,GAAwB;gBACjC,IAAI,EAAE,EAAE,CAAC,IAA+B;gBACxC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK;aAC/B,CAAC;YACF,OAAO,KAAK,CAAC;SACd;IACH,CAAC,CAAC;AACJ,CAAC;AAEQ,4BAAQ"} \ No newline at end of file diff --git a/dist/cjs/operators/general/index.d.ts b/dist/cjs/operators/general/index.d.ts index 7ca2742..617e56d 100644 --- a/dist/cjs/operators/general/index.d.ts +++ b/dist/cjs/operators/general/index.d.ts @@ -1,5 +1,6 @@ export * from "./branchAndMerge.js"; export * from "./dedup.js"; +export * from "./distribute.js"; export * from "./filter.js"; export * from "./flatten.js"; export * from "./groupPer.js"; diff --git a/dist/cjs/operators/general/index.js b/dist/cjs/operators/general/index.js index 12604ef..0805612 100644 --- a/dist/cjs/operators/general/index.js +++ b/dist/cjs/operators/general/index.js @@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./branchAndMerge.js"), exports); __exportStar(require("./dedup.js"), exports); +__exportStar(require("./distribute.js"), exports); __exportStar(require("./filter.js"), exports); __exportStar(require("./flatten.js"), exports); __exportStar(require("./groupPer.js"), exports); diff --git a/dist/cjs/operators/general/index.js.map b/dist/cjs/operators/general/index.js.map index ebccfdb..5ab0733 100644 --- a/dist/cjs/operators/general/index.js.map +++ b/dist/cjs/operators/general/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/operators/general/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AAEpC,6CAA2B;AAE3B,8CAA4B;AAE5B,+CAA6B;AAE7B,gDAA8B;AAE9B,gDAA8B;AAE9B,mDAAiC;AAEjC,2CAAyB;AAEzB,4CAA0B;AAE1B,gDAA8B;AAE9B,8CAA4B;AAE5B,8CAA4B;AAE5B,kDAAgC;AAEhC,qDAAmC;AAEnC,4CAA0B;AAE1B,iDAA+B;AAE/B,4CAA0B;AAE1B,6CAA2B;AAE3B,4CAA0B;AAE1B,iDAA+B;AAE/B,2CAAyB;AAEzB,4CAA0B;AAE1B,8CAA4B;AAE5B,2CAAyB"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/operators/general/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AAEpC,6CAA2B;AAE3B,kDAAgC;AAEhC,8CAA4B;AAE5B,+CAA6B;AAE7B,gDAA8B;AAE9B,gDAA8B;AAE9B,mDAAiC;AAEjC,2CAAyB;AAEzB,4CAA0B;AAE1B,gDAA8B;AAE9B,8CAA4B;AAE5B,8CAA4B;AAE5B,kDAAgC;AAEhC,qDAAmC;AAEnC,4CAA0B;AAE1B,iDAA+B;AAE/B,4CAA0B;AAE1B,6CAA2B;AAE3B,4CAA0B;AAE1B,iDAA+B;AAE/B,2CAAyB;AAEzB,4CAA0B;AAE1B,8CAA4B;AAE5B,2CAAyB"} \ No newline at end of file diff --git a/dist/cjs/operators/general/tap.d.ts b/dist/cjs/operators/general/tap.d.ts index b6b645a..34aee67 100644 --- a/dist/cjs/operators/general/tap.d.ts +++ b/dist/cjs/operators/general/tap.d.ts @@ -6,5 +6,5 @@ * * @category operators/general */ -declare const tap: (tapFn: (TIn: any) => void) => import("../../types.js").TTransIteratorSyncOrAsync; +declare const tap: (tapFn: (value: TIn) => void) => import("../../types.js").TTransIteratorSyncOrAsync; export { tap }; diff --git a/dist/cjs/operators/general/tap.js.map b/dist/cjs/operators/general/tap.js.map index 89c31af..4410ec9 100644 --- a/dist/cjs/operators/general/tap.js.map +++ b/dist/cjs/operators/general/tap.js.map @@ -1 +1 @@ -{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../../src/operators/general/tap.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC;;;;;;;GAOG;AACH,MAAM,GAAG,GAAG,CAAM,KAAoB,EAAE,EAAE,CACxC,IAAA,sBAAQ,EACN,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IACjB,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACvB;SAAM;QACL,IAAI;YACF,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;KAC7C;AACH,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AAEK,kBAAG"} \ No newline at end of file +{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../../src/operators/general/tap.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAEzC;;;;;;;GAOG;AACH,MAAM,GAAG,GAAG,CAAM,KAA2B,EAAE,EAAE,CAC/C,IAAA,sBAAQ,EACN,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IACjB,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACvB;SAAM;QACL,IAAI;YACF,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;KAC7C;AACH,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AAEK,kBAAG"} \ No newline at end of file diff --git a/dist/itr8.min.js b/dist/itr8.min.js index 2b10ad1..bb1d9d2 100644 --- a/dist/itr8.min.js +++ b/dist/itr8.min.js @@ -1,10 +1,10 @@ -var d=function(e){return e!=null&&Object.prototype.toString.call(e)==="[object Promise]"},L=Object.getPrototypeOf(async function(){}).constructor,p=r=>{if(d(r)){let e={src:r,then:(...t)=>p(r.then(...t))};return r.then(t=>e.value=t),e}else return typeof r?.then=="function"?r:{src:r?.src!==void 0?r.src:r,then:t=>{let n=p(t(r,!0));return n.value=n.src,n},value:r}},N=r=>{let e,t=!0;return d(r)?function(o){let u={src:o,then:(...a)=>{if(t){t=!1;let i=o.then(...a);return e=N(i),e(i)}return e(o.then(...a))}};return o.then(a=>u.value=a),u}:function(o){return t=!0,typeof o?.then=="function"?o:{src:o?.src!==void 0?o.src:o,then:a=>{if(t){t=!1;let c=a(o,!0);e=N(c);let I=e(c);return I.value=I.src,I}let i=e(a(o,!0));return i.value=i.src,i},value:o}}},P=r=>e=>d(e)?e.then(r):r(e),G=r=>{let e={asyncDoAfter:async t=>r(await t),syncDoAfter:r,doAfter:t=>(d(t)?e.doAfter=e.asyncDoAfter:e.doAfter=e.syncDoAfter,e.doAfter(t))};return e},D=(r,e,t,n)=>p(r()).then((o,u)=>p(e(o)).then((a,i)=>a?p(n(o)).then((c,I)=>p(t(o)).then((l,y)=>{if(u&&i&&I&&y){let T=l;for(;e(T);)n(T),T=t(T);return T}else return new L("firstStateAfterEach","testBeforeEach","codeToExecute","afterEach",` +var I=function(e){return e!=null&&Object.prototype.toString.call(e)==="[object Promise]"},L=Object.getPrototypeOf(async function(){}).constructor,p=r=>{if(I(r)){let e={src:r,then:(...t)=>p(r.then(...t))};return r.then(t=>e.value=t),e}else return typeof r?.then=="function"?r:{src:r?.src!==void 0?r.src:r,then:t=>{let n=p(t(r,!0));return n.value=n.src,n},value:r}},N=r=>{let e,t=!0;return I(r)?function(o){let u={src:o,then:(...a)=>{if(t){t=!1;let s=o.then(...a);return e=N(s),e(s)}return e(o.then(...a))}};return o.then(a=>u.value=a),u}:function(o){return t=!0,typeof o?.then=="function"?o:{src:o?.src!==void 0?o.src:o,then:a=>{if(t){t=!1;let c=a(o,!0);e=N(c);let T=e(c);return T.value=T.src,T}let s=e(a(o,!0));return s.value=s.src,s},value:o}}},R=r=>e=>I(e)?e.then(r):r(e),G=r=>{let e={asyncDoAfter:async t=>r(await t),syncDoAfter:r,doAfter:t=>(I(t)?e.doAfter=e.asyncDoAfter:e.doAfter=e.syncDoAfter,e.doAfter(t))};return e},D=(r,e,t,n)=>p(r()).then((o,u)=>p(e(o)).then((a,s)=>a?p(n(o)).then((c,T)=>p(t(o)).then((l,b)=>{if(u&&s&&T&&b){let d=l;for(;e(d);)n(d),d=t(d);return d}else return new L("firstStateAfterEach","testBeforeEach","codeToExecute","afterEach",` let state = firstStateAfterEach; - while (${i?"":"await "}testBeforeEach(state)) { - ${I?"":"await "}codeToExecute(state); - state = ${y?"":"await "}afterEach(state); + while (${s?"":"await "}testBeforeEach(state)) { + ${T?"":"await "}codeToExecute(state); + state = ${b?"":"await "}afterEach(state); } return state; - `)(l,e,n,t)})):o));function H(r,...e){return e.length===0?r:e.reduce((t,n)=>o=>n(t(o)),r)}function O(r,e,...t){return t.length===0?e(r):t.reduce((o,u)=>a=>u(o(a)),e)(r)}var w=function(r,e){return t=>{let n=0,o=e?.concurrency||1,u=new Set,a=async()=>{u.size>=o&&await Promise.race(u)},i=l=>{u.add(l),l.finally(()=>{u.delete(l)})},c=l=>{let y=T=>{if(n<1){try{t.throw?.(T)}catch{}n+=1}};try{let T=r(l);if(d(T))return c=b=>r(b).catch(y),T.catch(y),T;c=b=>{try{r(b)}catch(S){throw y(S),S}}}catch(T){throw y(T),T}},I=t.next();if(d(I)){let l=I,y=async T=>{await a();let b=c(T);d(b)&&i(b)};return(async()=>{let T=await l;for(;!T.done;)await y(T.value),T=await t.next();await Promise.all(u),t.return?.(T.value)})()}else{let l=I;if(l.done)t.return?.(l.value);else{let y=c(l.value);if(d(y))return(async()=>{let T=y;for(;!l.done;){let b=T||c(l.value);T=void 0,i(b),l=t.next(),await a()}await Promise.all(u),t.return?.(l.value)})();for(l=t.next();!l.done;l=t.next())c(l.value);t.return?.(l.value)}}}};function U(r){return r[Symbol.iterator]()}function X(r){return async function*(){for(let e of r)yield e}()}function $(r){let e={[Symbol.iterator]:()=>e,[Symbol.asyncIterator]:()=>e,next:()=>p(r()).then(t=>({done:!1,value:t})).src};return e}function h(r){return r[Symbol.iterator]?r[Symbol.iterator]():r[Symbol.asyncIterator]()}function g(r){return function*(){yield r}()}function Z(r){return async function*(){yield r}()}function F(r){return h(r)}function ne(r){return async function*(){for(let e of r)yield e}()}function v(r){let e=[],t,n,o=()=>{for(n=new Promise(a=>{t=a}),e.push(n);r!==void 0&&e.length>r+1;)e.shift()};o();let u={[Symbol.asyncIterator]:()=>u,next:async()=>{if(e.length>0)return await e.shift();throw new Error("[itr8FromObservable] No elements in the buffer?")},push:a=>{t({value:a}),o()},done:()=>{t({done:!0}),o()}};return u}function se(r){let e=v(1/0),t=setInterval(()=>{e.push(Date.now())},r),n=e.done;return e.done=()=>(clearInterval(t),n()),e}function le(r,e,t){let n=t!==void 0?Math.abs(t):1,o=r=e;u=u-n)yield u}()}function ce(r,e,t){let n=t!==void 0?Math.abs(t):1,o=r=e;u=u-n)yield u}()}function E(r){let e=r.next();if(d(e))return(async()=>{let t=[];for(;!(await e).done;)t.push((await e).value),e=r.next();return t})();{let t=[];for(let n=e;!n.done;n=r.next())t.push(n.value);return t}}function me(r){let e=r.next();if(d(e))return(async()=>{let t={};for(;!(await e).done;){let[n,o]=(await e).value;t[n]=o,e=r.next()}return t})();{let t={},n=e;for(;!n.done;){let[o,u]=n.value;t[o]=u,n=r.next()}return t}}function Oe(r){let e=r.next();if(d(e))return(async()=>{let t="";for(;!(await e).done;)t=t+(await e).value,e=r.next();return t})();{let t="",n=e;for(;!n.done;)t=t+n.value,n=r.next();return t}}var s=function(r,e){let t=(o,u)=>{let a={state:u,currentOutputIterator:void 0,isLastOutputIterator:!1},i=()=>O(o.next(),P(f=>r(f,a.state)),P(f=>{if("state"in f&&f.state!==void 0&&(a.state=f.state),f.done)return m.next=c,{done:!0,value:void 0};if("value"in f)return f.isLast&&(m.next=c),{done:!1,value:f.value};if("iterable"in f){if(a.currentOutputIterator!==void 0)throw new Error("currentOutputIterator should be undefined at this point");if(a.currentOutputIterator=h(f.iterable),a.isLastOutputIterator=!!f.isLast,a.currentOutputIterator?.next===void 0)throw new Error("Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)");return O(a.currentOutputIterator.next(),P(x=>x.done?(a.currentOutputIterator=void 0,null):x))}else return null})),c=()=>({done:!0,value:void 0}),I=()=>{let f=a.currentOutputIterator.next();return f.done?(a.currentOutputIterator=void 0,a.isLastOutputIterator?(m.next=c,{done:!0,value:void 0}):(m.next=l,m.next())):f},l=()=>{for(;;){let f=r(o.next(),a.state);if("state"in f&&(a.state=f.state),f.done)return m.next=c,{done:!0,value:void 0};if("value"in f)return f.isLast&&(m.next=c),{done:!1,value:f.value};if("iterable"in f){if(a.currentOutputIterator!==void 0)throw new Error("currentOutputIterator should be undefined at this point");if(a.currentOutputIterator=h(f.iterable),a.isLastOutputIterator=!!f.isLast,a.currentOutputIterator?.next===void 0)throw new Error("Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)");return m.next=I,m.next()}}},y,T,b,S=async()=>({done:!0,value:void 0}),B=async()=>{if(a.currentOutputIterator){let f=a.currentOutputIterator.next();y===void 0&&(y=d(f));let x=y?await f:f;return x.done?(a.currentOutputIterator=void 0,a.isLastOutputIterator?(m.next=S,{done:!0,value:void 0}):(m.next=C,m.next())):x}},C=async()=>{for(;;){let f=o.next();T===void 0&&(T=d(f));let x=T?await f:f,R=r(x,a.state);b===void 0&&(b=d(R));let A=b?await R:R;if("state"in A&&(a.state=A.state),A.done)return m.next=S,{done:A.done,value:void 0};if("value"in A)return A.isLast&&(m.next=S),{done:!1,value:A.value};if("iterable"in A){if(a.currentOutputIterator!==void 0)throw new Error("currentOutputIterator should be undefined at this point");if(a.currentOutputIterator=h(A.iterable),a.isLastOutputIterator=!!A.isLast,a.currentOutputIterator?.next===void 0)throw new Error("Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)");return m.next=B,m.next()}}},m={[Symbol.iterator]:()=>m,[Symbol.asyncIterator]:()=>m,next:()=>{let f=i();return d(f)?(async()=>{let x=await f;return m.next=a.currentOutputIterator===void 0?C:B,x!==null?x:m.next()})():(m.next=a.currentOutputIterator===void 0?l:I,f!==null?f:m.next())},return:f=>(o.return?.(),m.next===l?{done:!0,value:f}:Promise.resolve({done:!0,value:f})),throw:f=>(o.throw?.(f),m.next===l?{done:!0,value:void 0}:Promise.resolve({done:!0,value:void 0}))};return m},n=o=>{try{return t(o,e())}catch(u){throw o.throw?.(),u}};return n.transNextFn=o=>{let u={state:e(),currentOutputIterator:void 0,isLastOutputIterator:!1};if(o.done===!0)return o;if("iterable"in o){let a=o.iterable[Symbol.iterator]||o.iterable[Symbol.asyncIterator],i=[],c=D(()=>a.next(),I=>I.done!==!0,I=>a.next(),I=>{p(r(I,u.state)).then(l=>{u.state=l.state,l.done===!1&&l.iterable?i.push(...l.iterable):i.push(l.value)}).src});return p(c).then(I=>({done:!1,iterable:i})).src}else return"value"in o?p(r(o,u.state)).then(a=>{let{newState:i,...c}=a;return u.state=a.state,c}).src:o},n};var V=r=>s((e,t)=>e.done?{done:!0}:p(r(e.value)).then(n=>n?{done:!1,value:e.value}:{done:!0}).src,()=>{});function k(r){let e=new Map,t=new Map,n=()=>{let a=Math.min(...e.values());O(t.keys(),V(i=>i{t.delete(i)}))},o=()=>{let a={[Symbol.iterator]:()=>a,[Symbol.asyncIterator]:()=>a,next:()=>{let i=e.get(a);return t.has(i)||t.set(i,r.next()),n(),e.set(a,i+1),t.get(i)??{done:!0}},return:i=>(e.delete(a),n(),{done:!0,value:i}),throw:i=>(e.delete(a),n(),{done:!0,value:void 0})};return e.set(a,t.size===0?0:Math.min(...t.keys())),a};return{[Symbol.asyncIterator]:()=>o(),[Symbol.iterator]:()=>o()}}var Qe=r=>e=>{let t={value:r},n,o=async()=>{let a;do d(a)&&await a,t=await e.next(),a=new Promise((i,c)=>{n=i});while(!t.done)},u={[Symbol.asyncIterator]:()=>u,next:async()=>(n===void 0?o():n(!0),t),return:async a=>(e.return?.(),{done:!0,value:a}),throw:async a=>(e.throw?.(a),{done:!0,value:void 0})};return u};var et=r=>e=>{let t=[],n,o=async()=>{if(t.length0&&await t[0];let a=e.next();d(a)&&(n=!0,a.then(i=>{i.done||o()})),t.push(a)}},u={[Symbol.asyncIterator]:()=>u,[Symbol.iterator]:()=>u,next:()=>{if(o(),t.length>0){let[a,...i]=t;return t=i,o(),a}return n?Promise.resolve({done:!0,value:void 0}):{done:!0,value:void 0}},return:a=>(e.return?.(),n?Promise.resolve({done:!0,value:a}):{done:!0,value:a}),throw:a=>(e.throw?.(a),n?Promise.resolve({done:!0,value:void 0}):{done:!0,value:void 0})};return u};function ot(r,e,...t){let n=t.reduce((o,u)=>a=>u(o(a)),e);return r.keepOrder===void 0||r.keepOrder?o=>{async function*u(){let a=v();(async()=>(await O(o,w(async i=>{let c={callbackIt:v(),subIt:v()};a.push(c);let I=n(g(i));await w(l=>{c.subIt.push(l)})(I),c.subIt.done(),await E(c.callbackIt)},{concurrency:r.concurrency})),a.done()))();for await(let i of a)yield*i.subIt,i.callbackIt.done()}return u()}:o=>{async function*u(){let a=v();(async()=>(await O(o,w(async i=>{let c=n(g(i));await w(l=>a.push({value:l}))(c);let I=v();a.push({callbackIt:I}),await E(I)},{concurrency:r.concurrency})),a.done()))();for await(let i of a)i.callbackIt===void 0?yield i.value:i.callbackIt.done()}return u()}}var dt=r=>s((e,t)=>t.done?{done:!0}:e.done?{done:!1,value:!0,state:{done:!0}}:p(r(e.value)).then(n=>n?{done:!1,state:{done:!1}}:{done:!1,value:n,state:{done:!0}}).src,()=>({done:!1}));var mt=r=>s((e,t)=>t.done?{done:!0}:e.done?{done:!1,value:!1,state:{done:!0}}:p(r(e.value)).then(n=>n?{done:!1,value:n,state:{done:!0}}:{done:!1,state:{done:!1}}).src,()=>({done:!1}));var M=r=>{let e=o=>({done:!1,value:o}),t=async o=>({done:!1,value:await o}),n=o=>(d(o)?n=t:n=e,n(o));return s((o,u)=>o.done?{done:!0}:n(r(o.value)),()=>{})};function gt(r,...e){return function(t){let n=k(t),o=h(n),u=e.map(c=>O(h(n),c)),a;return O(o,M(c=>{let I=u.map(l=>l.next());if(a===void 0&&(a=I.some(l=>d(l))),a===!1)return[c,...I.map(l=>l.value)];if(a===!0){let l=[];return(async()=>{for await(let y of I)l.push(y.value);return[c,...l]})()}}))}}var Nt=r=>s((e,t)=>{if(e.done)return{done:!0};let n=r?r(e.value):e.value;return p(n).then(o=>o!==t?{done:!1,value:e.value,state:o}:{done:!1,state:o}).src},()=>{});var Mt=r=>{let e=function(t,n){let o=(u,a)=>u?{done:!1,value:a.value}:{done:!1};return e=d(t)?(u,a)=>u.then(i=>o(i,a)):o,e(t,n)};return s((t,n)=>t.done?{done:!0}:e(r(t.value),t),()=>{})};var Ht=()=>s((r,e)=>r.done?{done:!0}:{done:!1,iterable:r.value},()=>{});var Jt=r=>s((e,t)=>t.done||e.done&&t.buffer.length===0?{done:!0}:e.done?{done:!1,value:t.buffer,state:{done:!0,buffer:[]}}:t.buffer.length+1===r?{done:!1,value:[...t.buffer,e.value],state:{done:!1,buffer:[]}}:{done:!1,state:{...t,buffer:[...t.buffer,e.value]}},()=>({done:!1,buffer:[]}));function jt(){return function(r){if(r[Symbol.asyncIterator])return r;if(r[Symbol.iterator])return r;{let e={next:r.next,[Symbol.iterator]:()=>e};return e}}}var zt=r=>s((e,t)=>e.done?{done:!0}:t?{done:!1,iterable:[r,e.value],state:t}:{done:!1,iterable:[e.value],state:!0},()=>!1);var Qt=(r=1,e=1)=>s((t,n)=>{if(t.done){if(n.next.length===0||r===0)return{done:!0,state:{current:Symbol.ITR8_NO_CURRENT,next:[],previous:n.previous}};{let[o,...u]=n.next,a={current:o,next:u||[],previous:[n.current,...n.previous].slice(0,e)};return{done:!1,value:{value:a.current,next:a.next,previous:a.previous},state:a}}}else{if(n.next.length({previous:[],current:Symbol.ITR8_NO_CURRENT,next:[]}));var tr=(r,e)=>s((t,n)=>{if(n.done)return{done:!0};let o=n.accumulator;return t.done?{done:!1,value:o,state:{...n,done:!0}}:p(r(o,t.value,n.index)).then(u=>({done:!1,state:{...n,index:n.index+1,accumulator:u}})).src},()=>({index:0,accumulator:e,done:!1}));var or=(r=2)=>s((e,{list:t,remaining:n})=>n<=0?{done:!0}:e.done?{done:!1,iterable:t,state:{list:t,remaining:n-1}}:{done:!1,value:e.value,state:{list:t.concat(e.value),remaining:n}},()=>({list:[],remaining:r-1}));var sr=(r=2)=>s((e,t)=>e.done?{done:!0}:{done:!1,iterable:function*(){for(let n=0;n{});var cr=(r,e)=>s((t,n)=>{if(n.done)return{done:!0};let o=n.index===0?e:n.accumulator;return t.done?{done:!0,value:o,state:n}:p(r(o,t.value,n.index)).then(u=>({done:!1,value:u,state:{...n,index:n.index+1,accumulator:u}})).src},()=>({index:0,accumulator:e}));var Tr=(r=0)=>s((e,t)=>e.done?{done:!0}:t0);var br=r=>s((e,t)=>e.done?{done:!0}:t?p(r(e.value)).then((n,o)=>n?{done:!1,state:t}:{done:!1,value:e.value,state:!1}).src:{done:!1,value:e.value,state:!1},()=>!0);var Ar=r=>s((e,t)=>t.done?{done:!0}:e.done?{done:!1,iterable:t.list.sort(r||void 0),state:{...t,done:!0}}:{done:!1,state:{...t,list:[...t.list,e.value]}},()=>({done:!1,list:[]}));var wr=r=>s((e,t)=>e.done?t===null?{done:!0}:{done:!1,value:t,state:null}:e.value===r?{done:!1,value:t||[],state:[]}:{done:!1,state:[...t===null?[]:t,e.value]},()=>null);var Rr=(r=1/0)=>s((e,t)=>{if(e.done)return{done:!0};if(t0);var Br=r=>s((e,t)=>{if(e.done)return{done:!0};try{r(e.value)}catch(n){console.warn("Tap function caused an exception",n,n.stack)}return{done:!1,value:e.value}},()=>{});var Dr=()=>s((r,e)=>{if(r.done)return{done:!0};if(e.has(r.value))return{done:!1,state:e};let t=new Set(e);return t.add(r.value),{done:!1,value:r.value,state:t}},()=>new Set([]));var kr=r=>s((e,t)=>{if(e.done)return{done:!0};let n=r(e.value);if(t.has(n))return{done:!1,state:t};let o=new Set(t);return o.add(n),{done:!1,value:e.value,state:o}},()=>new Set([]));var Hr=r=>s((e,t)=>e.done?{done:!0}:p(r.next()).then(n=>({done:!1,value:[e.value,n.value]})).src,()=>{});var pn=()=>s((r,e)=>{if(e.done)return{done:!0};if(r.done)return{done:!1,value:e.sum/e.count,state:{...e,done:!0}};let t=e.count+1,n=e.sum+r.value;return{done:!1,state:{...e,count:t,sum:n}}},()=>({done:!1,count:0,sum:0}));var bn=()=>s((r,e)=>e.done?{done:!0}:r.done?{done:!1,value:e.max,state:{...e,done:!0}}:{done:!1,state:{...e,max:Math.max(e.max,r.value)}},()=>({done:!1,max:-1/0}));var An=()=>s((r,e)=>e.done?{done:!0}:r.done?{done:!1,value:e.min,state:{...e,done:!0}}:{done:!1,state:{...e,min:Math.min(e.min,r.value)}},()=>({done:!1,min:1/0}));var wn=r=>s((e,t)=>{if(t.done)return{done:!0};if(e.done)return{done:!1,value:t.topArray[0],state:{...t,done:!0}};let n=t.count+1,o=Math.floor((100-r)/100*n)+1,u=[...t.topArray,e.value];for(u.sort((a,i)=>a-i);o({done:!1,count:0,topArray:[]}));var Rn=()=>s((r,e)=>{if(r.done)return{done:!0};let t=e.count+1,n=e.sum+r.value;return{done:!1,state:{...e,count:t,sum:n},value:n/t}},()=>({done:!1,count:0,sum:0}));var Bn=r=>s((e,t)=>{if(e.done)return{done:!0};let n=t.count+1,o=Math.floor((100-r)/100*n)+1,u=[...t.topArray,e.value];for(u.sort((a,i)=>a-i);o({count:0,topArray:[]}));var Dn=()=>s((r,e)=>{if(r.done)return{done:!0};let t=e+r.value;return{done:!1,value:t,state:t}},()=>0);var kn=()=>s((r,e)=>e.done?{done:!0}:r.done?{done:!1,value:e.total,state:{...e,done:!0}}:{done:!1,state:{...e,total:e.total+r.value}},()=>({done:!1,total:0}));var zn=(r=` -`)=>s((e,{done:t,buffer:n})=>{if(e.done)return t?{done:!0,state:{done:!0,buffer:""}}:{done:!1,value:n,state:{done:!0,buffer:""}};{let o=e.value.split(r);return o.length===1?{done:!1,state:{done:!1,buffer:n+o[0]}}:o.length===2?{done:!1,value:n+o[0],state:{done:!1,buffer:o[1]}}:{done:!1,iterable:[n+o[0],...o.slice(1,-1)],state:{done:!1,buffer:o[o.length-1]}}}},()=>({done:!1,buffer:""}));var Yn=()=>s((r,e)=>r.done?{done:!0}:{done:!1,iterable:F(r.value)},()=>{});var oo=(r,e=t=>Date.now())=>s((t,n)=>{if(t.done)return{done:!0};let o=e(t.value);return o-n>r?{done:!1,value:t.value,state:o}:{done:!1,state:o}},()=>-1/0);var so=r=>s((e,t)=>new Promise(n=>{setTimeout(()=>n(e),r)}),()=>{});var fo=(r,e=t=>Date.now())=>s((t,n)=>{if(t.done)return{done:!0};let o=e(t.value);return o-n>r?{done:!1,value:t.value,state:o}:{done:!1,state:n}},()=>-1/0);export{L as AsyncFunction,pn as average,gt as branchAndMerge,H as compose,oo as debounce,Nt as dedup,so as delay,P as doAfter,G as doAfterFactory,dt as every,Mt as filter,Ht as flatten,w as forEach,D as forLoop,Jt as groupPer,jt as identity,zt as intersperse,d as isPromise,U as itr8FromArray,X as itr8FromArrayAsync,$ as itr8FromImpureFunction,h as itr8FromIterable,g as itr8FromSingleValue,Z as itr8FromSingleValueAsync,F as itr8FromString,ne as itr8FromStringAsync,se as itr8Interval,H as itr8Pipe,v as itr8Pushable,le as itr8Range,ce as itr8RangeAsync,E as itr8ToArray,k as itr8ToMultiIterable,me as itr8ToObject,Oe as itr8ToString,zn as lineByLine,M as map,bn as max,An as min,Qe as mostRecent,ot as parallel,Qt as peek,wn as percentile,O as pipe,s as powerMap,et as prefetch,tr as reduce,or as repeat,sr as repeatEach,Rn as runningAverage,Bn as runningPercentile,cr as runningReduce,Dn as runningTotal,Tr as skip,br as skipWhile,mt as some,Ar as sort,wr as split,Yn as stringToChar,Rr as take,V as takeWhile,Br as tap,p as thenable,N as thenableFactory,fo as throttle,kn as total,Dr as uniq,kr as uniqBy,Hr as zip}; + `)(l,e,n,t)})):o));function H(r,...e){return e.length===0?r:e.reduce((t,n)=>o=>n(t(o)),r)}function h(r,e,...t){return t.length===0?e(r):t.reduce((o,u)=>a=>u(o(a)),e)(r)}var P=function(r,e){return t=>{let n=0,o=e?.concurrency||1,u=new Set,a=async()=>{u.size>=o&&await Promise.race(u)},s=l=>{u.add(l),l.finally(()=>{u.delete(l)})},c=l=>{let b=d=>{if(n<1){try{t.throw?.(d)}catch{}n+=1}};try{let d=r(l);if(I(d))return c=m=>r(m).catch(b),d.catch(b),d;c=m=>{try{r(m)}catch(O){throw b(O),O}}}catch(d){throw b(d),d}},T=t.next();if(I(T)){let l=T,b=async d=>{await a();let m=c(d);I(m)&&s(m)};return(async()=>{let d=await l;for(;!d.done;)await b(d.value),d=await t.next();await Promise.all(u),t.return?.(d.value)})()}else{let l=T;if(l.done)t.return?.(l.value);else{let b=c(l.value);if(I(b))return(async()=>{let d=b;for(;!l.done;){let m=d||c(l.value);d=void 0,s(m),l=t.next(),await a()}await Promise.all(u),t.return?.(l.value)})();for(l=t.next();!l.done;l=t.next())c(l.value);t.return?.(l.value)}}}};function U(r){return r[Symbol.iterator]()}function X(r){return async function*(){for(let e of r)yield e}()}function z(r){let e={[Symbol.iterator]:()=>e,[Symbol.asyncIterator]:()=>e,next:()=>p(r()).then(t=>({done:!1,value:t})).src};return e}function A(r){return r[Symbol.iterator]?r[Symbol.iterator]():r[Symbol.asyncIterator]()}function C(r){return function*(){yield r}()}function Z(r){return async function*(){yield r}()}function F(r){return A(r)}function ne(r){return async function*(){for(let e of r)yield e}()}function S(r){let e=[],t,n,o=()=>{for(n=new Promise(a=>{t=a}),e.push(n);r!==void 0&&e.length>r+1;)e.shift()};o();let u={[Symbol.asyncIterator]:()=>u,next:async()=>{if(e.length>0)return await e.shift();throw new Error("[itr8FromObservable] No elements in the buffer?")},push:a=>{t({value:a}),o()},done:()=>{t({done:!0}),o()}};return u}function se(r){let e=S(1/0),t=setInterval(()=>{e.push(Date.now())},r),n=e.done;return e.done=()=>(clearInterval(t),n()),e}function le(r,e,t){let n=t!==void 0?Math.abs(t):1,o=r=e;u=u-n)yield u}()}function ce(r,e,t){let n=t!==void 0?Math.abs(t):1,o=r=e;u=u-n)yield u}()}function E(r){let e=r.next();if(I(e))return(async()=>{let t=[];for(;!(await e).done;)t.push((await e).value),e=r.next();return t})();{let t=[];for(let n=e;!n.done;n=r.next())t.push(n.value);return t}}function me(r){let e=r.next();if(I(e))return(async()=>{let t={};for(;!(await e).done;){let[n,o]=(await e).value;t[n]=o,e=r.next()}return t})();{let t={},n=e;for(;!n.done;){let[o,u]=n.value;t[o]=u,n=r.next()}return t}}function Oe(r){let e=r.next();if(I(e))return(async()=>{let t="";for(;!(await e).done;)t=t+(await e).value,e=r.next();return t})();{let t="",n=e;for(;!n.done;)t=t+n.value,n=r.next();return t}}var i=function(r,e){let t=(o,u)=>{let a={state:u,currentOutputIterator:void 0,isLastOutputIterator:!1},s=()=>h(o.next(),R(f=>r(f,a.state)),R(f=>{if("state"in f&&f.state!==void 0&&(a.state=f.state),f.done)return y.next=c,{done:!0,value:void 0};if("value"in f)return f.isLast&&(y.next=c),{done:!1,value:f.value};if("iterable"in f){if(a.currentOutputIterator!==void 0)throw new Error("currentOutputIterator should be undefined at this point");if(a.currentOutputIterator=A(f.iterable),a.isLastOutputIterator=!!f.isLast,a.currentOutputIterator?.next===void 0)throw new Error("Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)");return h(a.currentOutputIterator.next(),R(w=>w.done?(a.currentOutputIterator=void 0,null):w))}else return null})),c=()=>({done:!0,value:void 0}),T=()=>{let f=a.currentOutputIterator.next();return f.done?(a.currentOutputIterator=void 0,a.isLastOutputIterator?(y.next=c,{done:!0,value:void 0}):(y.next=l,y.next())):f},l=()=>{for(;;){let f=r(o.next(),a.state);if("state"in f&&(a.state=f.state),f.done)return y.next=c,{done:!0,value:void 0};if("value"in f)return f.isLast&&(y.next=c),{done:!1,value:f.value};if("iterable"in f){if(a.currentOutputIterator!==void 0)throw new Error("currentOutputIterator should be undefined at this point");if(a.currentOutputIterator=A(f.iterable),a.isLastOutputIterator=!!f.isLast,a.currentOutputIterator?.next===void 0)throw new Error("Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)");return y.next=T,y.next()}}},b,d,m,O=async()=>({done:!0,value:void 0}),x=async()=>{if(a.currentOutputIterator){let f=a.currentOutputIterator.next();b===void 0&&(b=I(f));let w=b?await f:f;return w.done?(a.currentOutputIterator=void 0,a.isLastOutputIterator?(y.next=O,{done:!0,value:void 0}):(y.next=B,y.next())):w}},B=async()=>{for(;;){let f=o.next();d===void 0&&(d=I(f));let w=d?await f:f,g=r(w,a.state);m===void 0&&(m=I(g));let v=m?await g:g;if("state"in v&&(a.state=v.state),v.done)return y.next=O,{done:v.done,value:void 0};if("value"in v)return v.isLast&&(y.next=O),{done:!1,value:v.value};if("iterable"in v){if(a.currentOutputIterator!==void 0)throw new Error("currentOutputIterator should be undefined at this point");if(a.currentOutputIterator=A(v.iterable),a.isLastOutputIterator=!!v.isLast,a.currentOutputIterator?.next===void 0)throw new Error("Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)");return y.next=x,y.next()}}},y={[Symbol.iterator]:()=>y,[Symbol.asyncIterator]:()=>y,next:()=>{let f=s();return I(f)?(async()=>{let w=await f;return y.next=a.currentOutputIterator===void 0?B:x,w!==null?w:y.next()})():(y.next=a.currentOutputIterator===void 0?l:T,f!==null?f:y.next())},return:f=>(o.return?.(),y.next===l?{done:!0,value:f}:Promise.resolve({done:!0,value:f})),throw:f=>(o.throw?.(f),y.next===l?{done:!0,value:void 0}:Promise.resolve({done:!0,value:void 0}))};return y},n=o=>{try{return t(o,e())}catch(u){throw o.throw?.(),u}};return n.transNextFn=o=>{let u={state:e(),currentOutputIterator:void 0,isLastOutputIterator:!1};if(o.done===!0)return o;if("iterable"in o){let a=o.iterable[Symbol.iterator]||o.iterable[Symbol.asyncIterator],s=[],c=D(()=>a.next(),T=>T.done!==!0,T=>a.next(),T=>{p(r(T,u.state)).then(l=>{u.state=l.state,l.done===!1&&l.iterable?s.push(...l.iterable):s.push(l.value)}).src});return p(c).then(T=>({done:!1,iterable:s})).src}else return"value"in o?p(r(o,u.state)).then(a=>{let{newState:s,...c}=a;return u.state=a.state,c}).src:o},n};var M=r=>i((e,t)=>e.done?{done:!0}:p(r(e.value)).then(n=>n?{done:!1,value:e.value}:{done:!0}).src,()=>{});function V(r){let e=new Map,t=new Map,n=()=>{let a=Math.min(...e.values());h(t.keys(),M(s=>s{t.delete(s)}))},o=()=>{let a={[Symbol.iterator]:()=>a,[Symbol.asyncIterator]:()=>a,next:()=>{let s=e.get(a);return t.has(s)||t.set(s,r.next()),n(),e.set(a,s+1),t.get(s)??{done:!0}},return:s=>(e.delete(a),n(),{done:!0,value:s}),throw:s=>(e.delete(a),n(),{done:!0,value:void 0})};return e.set(a,t.size===0?0:Math.min(...t.keys())),a};return{[Symbol.asyncIterator]:()=>o(),[Symbol.iterator]:()=>o()}}var Ye=r=>e=>{let t={value:r},n,o=async()=>{let a;do I(a)&&await a,t=await e.next(),a=new Promise((s,c)=>{n=s});while(!t.done)},u={[Symbol.asyncIterator]:()=>u,next:async()=>(n===void 0?o():n(!0),t),return:async a=>(e.return?.(),{done:!0,value:a}),throw:async a=>(e.throw?.(a),{done:!0,value:void 0})};return u};var et=r=>e=>{let t=[],n,o=async()=>{if(t.length0&&await t[0];let a=e.next();I(a)&&(n=!0,a.then(s=>{s.done||o()})),t.push(a)}},u={[Symbol.asyncIterator]:()=>u,[Symbol.iterator]:()=>u,next:()=>{if(o(),t.length>0){let[a,...s]=t;return t=s,o(),a}return n?Promise.resolve({done:!0,value:void 0}):{done:!0,value:void 0}},return:a=>(e.return?.(),n?Promise.resolve({done:!0,value:a}):{done:!0,value:a}),throw:a=>(e.throw?.(a),n?Promise.resolve({done:!0,value:void 0}):{done:!0,value:void 0})};return u};function ot(r,e,...t){let n=t.reduce((o,u)=>a=>u(o(a)),e);return r.keepOrder===void 0||r.keepOrder?o=>{async function*u(){let a=S();(async()=>(await h(o,P(async s=>{let c={callbackIt:S(),subIt:S()};a.push(c);let T=n(C(s));await P(l=>{c.subIt.push(l)})(T),c.subIt.done(),await E(c.callbackIt)},{concurrency:r.concurrency})),a.done()))();for await(let s of a)yield*s.subIt,s.callbackIt.done()}return u()}:o=>{async function*u(){let a=S();(async()=>(await h(o,P(async s=>{let c=n(C(s));await P(l=>a.push({value:l}))(c);let T=S();a.push({callbackIt:T}),await E(T)},{concurrency:r.concurrency})),a.done()))();for await(let s of a)s.callbackIt===void 0?yield s.value:s.callbackIt.done()}return u()}}var dt=r=>i((e,t)=>t.done?{done:!0}:e.done?{done:!1,value:!0,state:{done:!0}}:p(r(e.value)).then(n=>n?{done:!1,state:{done:!1}}:{done:!1,value:n,state:{done:!0}}).src,()=>({done:!1}));var mt=r=>i((e,t)=>t.done?{done:!0}:e.done?{done:!1,value:!1,state:{done:!0}}:p(r(e.value)).then(n=>n?{done:!1,value:n,state:{done:!0}}:{done:!1,state:{done:!1}}).src,()=>({done:!1}));var k=r=>{let e=o=>({done:!1,value:o}),t=async o=>({done:!1,value:await o}),n=o=>(I(o)?n=t:n=e,n(o));return i((o,u)=>o.done?{done:!0}:n(r(o.value)),()=>{})};function gt(r,...e){return function(t){let n=V(t),o=A(n),u=e.map(c=>h(A(n),c)),a;return h(o,k(c=>{let T=u.map(l=>l.next());if(a===void 0&&(a=T.some(l=>I(l))),a===!1)return[c,...T.map(l=>l.value)];if(a===!0){let l=[];return(async()=>{for await(let b of T)l.push(b.value);return[c,...l]})()}}))}}var Nt=r=>i((e,t)=>{if(e.done)return{done:!0};let n=r?r(e.value):e.value;return p(n).then(o=>o!==t?{done:!1,value:e.value,state:o}:{done:!1,state:o}).src},()=>{});function Vt(){let r=new Map,e=[],t=-1,n=!1,o=(s,c)=>{r.has(s)?r.get(s).push(c):(r.set(s,[c]),e.push(s))},u=s=>{if(r.has(s)){let c=r.get(s);if(c&&c.length>0)return c.shift()}return Symbol.categoryEmpty},a=s=>{s.done?n=!0:o(s.value[0],s.value[1])};return s=>{function*c(m){if(!r.has(m))throw new Error(`Category ${m} not found in bufferMap`);let O=!1;for(;!O;){let x=u(m);x!==Symbol.categoryEmpty?yield x:n?O=!0:a(s.next())}}function*T(m){for(let O=m;!O.done;O=s.next())for(a(O);t{let e=function(t,n){let o=(u,a)=>u?{done:!1,value:a.value}:{done:!1};return e=I(t)?(u,a)=>u.then(s=>o(s,a)):o,e(t,n)};return i((t,n)=>t.done?{done:!0}:e(r(t.value),t),()=>{})};var Jt=()=>i((r,e)=>r.done?{done:!0}:{done:!1,iterable:r.value},()=>{});var Xt=r=>i((e,t)=>t.done||e.done&&t.buffer.length===0?{done:!0}:e.done?{done:!1,value:t.buffer,state:{done:!0,buffer:[]}}:t.buffer.length+1===r?{done:!1,value:[...t.buffer,e.value],state:{done:!1,buffer:[]}}:{done:!1,state:{...t,buffer:[...t.buffer,e.value]}},()=>({done:!1,buffer:[]}));function $t(){return function(r){if(r[Symbol.asyncIterator])return r;if(r[Symbol.iterator])return r;{let e={next:r.next,[Symbol.iterator]:()=>e};return e}}}var Yt=r=>i((e,t)=>e.done?{done:!0}:t?{done:!1,iterable:[r,e.value],state:t}:{done:!1,iterable:[e.value],state:!0},()=>!1);var er=(r=1,e=1)=>i((t,n)=>{if(t.done){if(n.next.length===0||r===0)return{done:!0,state:{current:Symbol.ITR8_NO_CURRENT,next:[],previous:n.previous}};{let[o,...u]=n.next,a={current:o,next:u||[],previous:[n.current,...n.previous].slice(0,e)};return{done:!1,value:{value:a.current,next:a.next,previous:a.previous},state:a}}}else{if(n.next.length({previous:[],current:Symbol.ITR8_NO_CURRENT,next:[]}));var or=(r,e)=>i((t,n)=>{if(n.done)return{done:!0};let o=n.accumulator;return t.done?{done:!1,value:o,state:{...n,done:!0}}:p(r(o,t.value,n.index)).then(u=>({done:!1,state:{...n,index:n.index+1,accumulator:u}})).src},()=>({index:0,accumulator:e,done:!1}));var sr=(r=2)=>i((e,{list:t,remaining:n})=>n<=0?{done:!0}:e.done?{done:!1,iterable:t,state:{list:t,remaining:n-1}}:{done:!1,value:e.value,state:{list:t.concat(e.value),remaining:n}},()=>({list:[],remaining:r-1}));var fr=(r=2)=>i((e,t)=>e.done?{done:!0}:{done:!1,iterable:function*(){for(let n=0;n{});var Tr=(r,e)=>i((t,n)=>{if(n.done)return{done:!0};let o=n.index===0?e:n.accumulator;return t.done?{done:!0,value:o,state:n}:p(r(o,t.value,n.index)).then(u=>({done:!1,value:u,state:{...n,index:n.index+1,accumulator:u}})).src},()=>({index:0,accumulator:e}));var yr=(r=0)=>i((e,t)=>e.done?{done:!0}:t0);var Ar=r=>i((e,t)=>e.done?{done:!0}:t?p(r(e.value)).then((n,o)=>n?{done:!1,state:t}:{done:!1,value:e.value,state:!1}).src:{done:!1,value:e.value,state:!1},()=>!0);var vr=r=>i((e,t)=>t.done?{done:!0}:e.done?{done:!1,iterable:t.list.sort(r||void 0),state:{...t,done:!0}}:{done:!1,state:{...t,list:[...t.list,e.value]}},()=>({done:!1,list:[]}));var Rr=r=>i((e,t)=>e.done?t===null?{done:!0}:{done:!1,value:t,state:null}:e.value===r?{done:!1,value:t||[],state:[]}:{done:!1,state:[...t===null?[]:t,e.value]},()=>null);var Er=(r=1/0)=>i((e,t)=>{if(e.done)return{done:!0};if(t0);var Dr=r=>i((e,t)=>{if(e.done)return{done:!0};try{r(e.value)}catch(n){console.warn("Tap function caused an exception",n,n.stack)}return{done:!1,value:e.value}},()=>{});var Vr=()=>i((r,e)=>{if(r.done)return{done:!0};if(e.has(r.value))return{done:!1,state:e};let t=new Set(e);return t.add(r.value),{done:!1,value:r.value,state:t}},()=>new Set([]));var Gr=r=>i((e,t)=>{if(e.done)return{done:!0};let n=r(e.value);if(t.has(n))return{done:!1,state:t};let o=new Set(t);return o.add(n),{done:!1,value:e.value,state:o}},()=>new Set([]));var Jr=r=>i((e,t)=>e.done?{done:!0}:p(r.next()).then(n=>({done:!1,value:[e.value,n.value]})).src,()=>{});var On=()=>i((r,e)=>{if(e.done)return{done:!0};if(r.done)return{done:!1,value:e.sum/e.count,state:{...e,done:!0}};let t=e.count+1,n=e.sum+r.value;return{done:!1,state:{...e,count:t,sum:n}}},()=>({done:!1,count:0,sum:0}));var hn=()=>i((r,e)=>e.done?{done:!0}:r.done?{done:!1,value:e.max,state:{...e,done:!0}}:{done:!1,state:{...e,max:Math.max(e.max,r.value)}},()=>({done:!1,max:-1/0}));var Sn=()=>i((r,e)=>e.done?{done:!0}:r.done?{done:!1,value:e.min,state:{...e,done:!0}}:{done:!1,state:{...e,min:Math.min(e.min,r.value)}},()=>({done:!1,min:1/0}));var gn=r=>i((e,t)=>{if(t.done)return{done:!0};if(e.done)return{done:!1,value:t.topArray[0],state:{...t,done:!0}};let n=t.count+1,o=Math.floor((100-r)/100*n)+1,u=[...t.topArray,e.value];for(u.sort((a,s)=>a-s);o({done:!1,count:0,topArray:[]}));var Bn=()=>i((r,e)=>{if(r.done)return{done:!0};let t=e.count+1,n=e.sum+r.value;return{done:!1,state:{...e,count:t,sum:n},value:n/t}},()=>({done:!1,count:0,sum:0}));var Fn=r=>i((e,t)=>{if(e.done)return{done:!0};let n=t.count+1,o=Math.floor((100-r)/100*n)+1,u=[...t.topArray,e.value];for(u.sort((a,s)=>a-s);o({count:0,topArray:[]}));var kn=()=>i((r,e)=>{if(r.done)return{done:!0};let t=e+r.value;return{done:!1,value:t,state:t}},()=>0);var Hn=()=>i((r,e)=>e.done?{done:!0}:r.done?{done:!1,value:e.total,state:{...e,done:!0}}:{done:!1,state:{...e,total:e.total+r.value}},()=>({done:!1,total:0}));var Qn=(r=` +`)=>i((e,{done:t,buffer:n})=>{if(e.done)return t?{done:!0,state:{done:!0,buffer:""}}:{done:!1,value:n,state:{done:!0,buffer:""}};{let o=e.value.split(r);return o.length===1?{done:!1,state:{done:!1,buffer:n+o[0]}}:o.length===2?{done:!1,value:n+o[0],state:{done:!1,buffer:o[1]}}:{done:!1,iterable:[n+o[0],...o.slice(1,-1)],state:{done:!1,buffer:o[o.length-1]}}}},()=>({done:!1,buffer:""}));var ro=()=>i((r,e)=>r.done?{done:!0}:{done:!1,iterable:F(r.value)},()=>{});var io=(r,e=t=>Date.now())=>i((t,n)=>{if(t.done)return{done:!0};let o=e(t.value);return o-n>r?{done:!1,value:t.value,state:o}:{done:!1,state:o}},()=>-1/0);var co=r=>i((e,t)=>new Promise(n=>{setTimeout(()=>n(e),r)}),()=>{});var po=(r,e=t=>Date.now())=>i((t,n)=>{if(t.done)return{done:!0};let o=e(t.value);return o-n>r?{done:!1,value:t.value,state:o}:{done:!1,state:n}},()=>-1/0);export{L as AsyncFunction,On as average,gt as branchAndMerge,H as compose,io as debounce,Nt as dedup,co as delay,Vt as distribute,R as doAfter,G as doAfterFactory,dt as every,Ht as filter,Jt as flatten,P as forEach,D as forLoop,Xt as groupPer,$t as identity,Yt as intersperse,I as isPromise,U as itr8FromArray,X as itr8FromArrayAsync,z as itr8FromImpureFunction,A as itr8FromIterable,C as itr8FromSingleValue,Z as itr8FromSingleValueAsync,F as itr8FromString,ne as itr8FromStringAsync,se as itr8Interval,H as itr8Pipe,S as itr8Pushable,le as itr8Range,ce as itr8RangeAsync,E as itr8ToArray,V as itr8ToMultiIterable,me as itr8ToObject,Oe as itr8ToString,Qn as lineByLine,k as map,hn as max,Sn as min,Ye as mostRecent,ot as parallel,er as peek,gn as percentile,h as pipe,i as powerMap,et as prefetch,or as reduce,sr as repeat,fr as repeatEach,Bn as runningAverage,Fn as runningPercentile,Tr as runningReduce,kn as runningTotal,yr as skip,Ar as skipWhile,mt as some,vr as sort,Rr as split,ro as stringToChar,Er as take,M as takeWhile,Dr as tap,p as thenable,N as thenableFactory,po as throttle,Hn as total,Vr as uniq,Gr as uniqBy,Jr as zip}; //# sourceMappingURL=itr8.min.js.map diff --git a/dist/itr8.min.js.map b/dist/itr8.min.js.map index d5c5f8f..cabab03 100644 --- a/dist/itr8.min.js.map +++ b/dist/itr8.min.js.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../src/util/index.ts", "../src/interface/forEach.ts", "../src/interface/itr8FromArray.ts", "../src/interface/itr8FromArrayAsync.ts", "../src/interface/itr8FromImpureFunction.ts", "../src/interface/itr8FromIterable.ts", "../src/interface/itr8FromSingleValue.ts", "../src/interface/itr8FromSingleValueAsync.ts", "../src/interface/itr8FromString.ts", "../src/interface/itr8FromStringAsync.ts", "../src/interface/itr8Pushable.ts", "../src/interface/itr8Interval.ts", "../src/interface/itr8Range.ts", "../src/interface/itr8RangeAsync.ts", "../src/interface/itr8ToArray.ts", "../src/interface/itr8ToObject.ts", "../src/interface/itr8ToString.ts", "../src/operators/general/powerMap.ts", "../src/operators/general/takeWhile.ts", "../src/interface/itr8ToMultiIterable.ts", "../src/operators/async/mostRecent.ts", "../src/operators/async/prefetch.ts", "../src/operators/async/parallel.ts", "../src/operators/boolean/every.ts", "../src/operators/boolean/some.ts", "../src/operators/general/map.ts", "../src/operators/general/branchAndMerge.ts", "../src/operators/general/dedup.ts", "../src/operators/general/filter.ts", "../src/operators/general/flatten.ts", "../src/operators/general/groupPer.ts", "../src/operators/general/identity.ts", "../src/operators/general/intersperse.ts", "../src/operators/general/peek.ts", "../src/operators/general/reduce.ts", "../src/operators/general/repeat.ts", "../src/operators/general/repeatEach.ts", "../src/operators/general/runningReduce.ts", "../src/operators/general/skip.ts", "../src/operators/general/skipWhile.ts", "../src/operators/general/sort.ts", "../src/operators/general/split.ts", "../src/operators/general/take.ts", "../src/operators/general/tap.ts", "../src/operators/general/uniq.ts", "../src/operators/general/uniqBy.ts", "../src/operators/general/zip.ts", "../src/operators/numeric/average.ts", "../src/operators/numeric/max.ts", "../src/operators/numeric/min.ts", "../src/operators/numeric/percentile.ts", "../src/operators/numeric/runningAverage.ts", "../src/operators/numeric/runningPercentile.ts", "../src/operators/numeric/runningTotal.ts", "../src/operators/numeric/total.ts", "../src/operators/strings/lineByLine.ts", "../src/operators/strings/stringToChar.ts", "../src/operators/timeBased/debounce.ts", "../src/operators/timeBased/delay.ts", "../src/operators/timeBased/throttle.ts"], - "sourcesContent": ["/**\n * Utility functions that are used internally, but that can be used by anyone to\n * help create operators that support both synchronous and asynchronous parameters\n * (by using thenable, forLoop or isPromise).\n *\n * @module\n */\n\n// https://www.typescriptlang.org/play?#code/MYewdgzgLgBAhgLjAVwLYCMCmAnA2gXRgF4ZcBGA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-0pMNAHqswAaI1tGKOPih5EumHSZtnGAQC0LQrSpRDTOQizVswsRNrxfC7L2lb1qob9dDAKlJuwYG7oquGuIR57bsdUBTFKMQAAZQ34t6hPutqvoK5IudpnAxElnnVRgMgoalLkvFl6WGNQGmoGB21QZgcHFKV7qVPulmnu06aZy4GZ+FQOyccgPGKbWjacS20ndvvfbrKpzXueZWlGcdWH1NZnjQ0lNXxRIfmRUFwSPvE8WkijmWtel+XFfqpJftV9PxRcEhqe5nXtT1g2YSN7P9dN0PzaGy2YzjYm8JgAF+E3Lxa1wEB4IdsyUKp7AhDQBkoF-GBCDCFHrbgagifmnAvAM4c7C98c4Fqo4aPpzy7hgTOt7c3eIv3m9Wyg8tu1TXt14HAJgh8Vt2y7Ssb7vJ9766Lx0cxuZV-Jl4dAW9n4vyvm-asfZWhf0fvkW2JQAHryASAycVQgA\n\nimport { TThenable } from \"../types.js\";\n\n// THIS MIGHT BE AN ALTERNATIVE TO REMOVE THE DEPENDENCY to Node's uil/types\n////////////////////////////////////////////////////////////////////////////\n/**\n * Check whether the parameter is a promise.\n *\n * @param p\n * @returns true if p is a promise\n *\n * @category util\n */\nconst isPromise = function isPromise(p: unknown): p is Promise {\n return (\n p !== undefined &&\n p !== null &&\n Object.prototype.toString.call(p) === \"[object Promise]\"\n );\n};\n\n// import { isPromise } from 'util/types'\n\n// try {\n// // eslint-disable-next-line @typescript-eslint/no-var-requires\n// isPromise = require('util/types').isPromise;\n// } catch {\n// // ignore\n// }\n\n/**\n * Shim for allowing async function creation similar to new Function.\n *\n * Found here: https://davidwalsh.name/async-function-class\n *\n * @example\n * ```javascript\n * const fetchPage = new AsyncFunction(\"url\", \"return await fetch(url);\");\n * ```\n */\nconst AsyncFunction = Object.getPrototypeOf(async function () {\n /* empty */\n}).constructor;\n\n/**\n * (Word play on then-able an th-enable)\n *\n * This utility function makes sure that any value (Promise or otherwise)\n * will be turned into an object with a then property, so that we can write the same code\n * regardless of whether the input is sync or async, but guaranteeing that\n * if the input is sync, all operations will also be called synchronously.\n *\n * The original input object is available under the thenable(...).src property.\n *\n * After the then callback has finished, the Object's 'value' property will be set\n * to the 'resolved' value.\n *\n * @example\n * ```typescript\n * // the same code can be applied without changes to a promise or a non promise\n * // by doing it all in the then-callback\n * thenable(123)\n * .then(\n * (v) => {\n * console.log(v);\n * return getSomeOtherSyncOrAsyncVal(v);\n * }\n * )\n * .then(\n * (otherVal) => {\n * console.log(otherVal);\n * return getYetAnotherVal(v);\n * }\n * )\n * ```\n *\n * ???\n * MAYBE a better solution would be to have a function called ```doAfter(value, (value) => { your code })```\n * that checks whether it is a promise or not, and returns the result of the handler?\n * But without the pipe operator it would be a pain to chain them, unless it will return an object\n * with some properties like ```{ result, doAfter:... }```\n * or maybe thenable should always return a new object with properties ```{ src, then, finally, ... }``` so\n * that the interface resembles a promise, but if we need the actual promise or value\n * we should simply call src?\n *\n * @param x a Promise or a regular value\n * @returns an object that has a then function and a src property pointing to the original input\n * regardless whether it is a Promise or not\n *\n * @category util\n */\nconst thenable = (x: T): TThenable => {\n if (isPromise(x)) {\n // console.log(`[thenable] ASYNC: ${x}`);\n const newX = {\n src: x,\n then: (...args) => thenable(x.then(...args)),\n };\n // make sure the value gets added to this object after the promise resolves\n x.then((value) => (newX[\"value\"] = value));\n return newX;\n } else {\n // console.log(`[thenable] SYNC: ${x}`);\n if (typeof (x as any)?.then === \"function\") {\n return x as unknown as TThenable;\n } else {\n // needed, because in strict mode it is impossble to set a property\n // on a string primitive (and in non-strict mode the set value cannot be read again)\n const newX = {\n src: (x as any)?.src !== undefined ? (x as any).src : x,\n then: (okHandler: (v: unknown, isSync?: boolean) => unknown) => {\n const retVal = thenable(okHandler(x, true));\n retVal[\"value\"] = retVal.src;\n return retVal;\n },\n value: x,\n };\n return newX;\n }\n }\n};\n\n/**\n * After I created the thenable function, my code became easier, because I could write\n * the same code regardless whether the input was synchronous or asynchronous.\n * But by wrapping something with thenable, the check whether it was a Promise or not\n * was done on every invocation.\n *\n * In a library that is about iterators, we expect this to be called many times.\n * So it feels like it could make sense to create a version that 'remembers'\n * the conclusions from the first run, and that will use that knowledge in the second run\n * (assuming that every next element in an iterator will be a promise if the first was a promise\n * and vice versa)\n *\n * A few tests seemed to indicate that calling isPromise often if about 10x slower than\n * checking if a variable is true or false (or is a specific symbol), so there should be\n * gain to be made with this.\n *\n * @example\n * ```typescript\n * // instead of\n * for (x of [1, 2, 3]) {\n * thenable(x).then((v) => console.log(v));\n * }\n * // do something like\n * const cachedThenable = thenableFactory(1);\n * for (x of [1, 2, 3]) {\n * cachedThenable(x).then((v) => console.log(v))\n * }\n * ```\n *\n * @param x a simple value or a promise, for which you need to execute some code\n * @returns a thenable(...)-like function that has assumptions built-in based on the first x\n */\nconst thenableFactory = (\n y: T | Promise,\n): ((x: T | Promise) => TThenable) => {\n let cachedThenable;\n let firstRun = true;\n if (isPromise(y)) {\n // console.log(`[thenableFactory] ASYNC: ${y}`);\n // let genericThenAsync = (x: Promise, ...args) => {\n // const thenResult = x.then(...args);\n // if (firstRun) {\n // firstRun = false;\n // cachedThenable = thenableFactory(thenResult);\n // genericThenAsync = (x2: Promise, ...args) => cachedThenable(x2.then(...args));\n // }\n // return cachedThenable(thenResult);\n // };\n\n return function asyncThenable(x: Promise) {\n const newX = {\n src: x,\n then: (...args) => {\n if (firstRun) {\n firstRun = false;\n const thenResult = x.then(...args);\n cachedThenable = thenableFactory(thenResult);\n return cachedThenable(thenResult);\n }\n return cachedThenable(x.then(...args));\n },\n };\n // make sure the value gets added to this object after the promise resolves\n x.then((value) => (newX[\"value\"] = value));\n return newX;\n };\n // .bind({}); // needed for 'this' to work\n } else {\n // console.log(`[thenableFactory] SYNC: ${y}`);\n // let genericThenSync = (x: T, okHandler: (v: unknown, isSync?: boolean) => unknown) => {\n // if (firstRun) {\n // firstRun = false;\n // // console.log(`[thenableFactory] set cached thenable = ${okHandlerResult}`);\n // cachedThenable = thenableFactory(okHandlerResult);\n // // overwrite genericThenSync with a version that does not need to check anymore\n // genericThenSync = (x2: T, okHandler2: (v: unknown, isSync?: boolean) => unknown) => {\n // const retVal2 = cachedThenable(okHandler2(x2, true));\n // // console.log(`genericThenSync ${x2} -> ${retVal2.value}`);\n // retVal2[\"value\"] = retVal2.src;\n // return retVal2;\n // };\n // }\n // const retVal = cachedThenable(okHandlerResult);\n // retVal[\"value\"] = retVal.src;\n // return retVal;\n // };\n\n return function syncThenable(x: T) {\n firstRun = true;\n\n if (typeof (x as any)?.then === \"function\") {\n return x as unknown as TThenable;\n } else {\n // needed, because in strict mode it is impossble to set a property\n // on a string primitive (and in non-strict mode the set value cannot be read again)\n const newX = {\n src: (x as any)?.src !== undefined ? (x as any).src : x,\n then: (okHandler: (v: unknown, isSync?: boolean) => unknown) => {\n if (firstRun) {\n firstRun = false;\n // console.log(`[thenableFactory] set cached thenable = ${okHandlerResult}`);\n const okHandlerResult = okHandler(x, true);\n cachedThenable = thenableFactory(okHandlerResult);\n const retVal = cachedThenable(okHandlerResult);\n retVal[\"value\"] = retVal.src;\n return retVal;\n }\n const retVal = cachedThenable(okHandler(x, true));\n retVal[\"value\"] = retVal.src;\n return retVal;\n },\n value: x,\n };\n return newX;\n }\n };\n // .bind({}); // needed for 'this' to work\n }\n};\n\n/**\n * doAfter() will create another function that expects a singoe argument which could either be\n * a simple value or a promise, and doAfter will make sure that the given function is executed\n * synchronously if it's a simple value, or asynchronously after the promise resolves.\n *\n * Like thenable, but trying to avoid the creation of all the intermediate objects.\n * With our pipe function, it should be easy to use.\n *\n * @example\n * ```\n * pipe(\n * promiseOrValue,\n * doAfter((v) => { do sync or async stuff with v and return the result }),\n * doAfter((w) => { do sync or async stuff and return the result }),\n * )\n * ```\n */\nconst doAfter = (\n f: (v: TIn) => TOut | Promise,\n): ((x: TIn | Promise) => TOut | Promise) => {\n return (valueOrPromise: TIn | Promise) => {\n return isPromise(valueOrPromise)\n ? (valueOrPromise.then(f) as Promise)\n : (f(valueOrPromise) as TOut);\n };\n};\n\n/**\n * Like doAfter, but remembers whether the sync or the async route should be chosen\n * based on the first call.\n * This could speed up things by avoiding repeated isPromise calls.\n * @example\n * ```typescript\n * const incrementAfter = doAfterFactory((n) => n + 1);\n * const doubleAfter = doAfterFactory((n) => n * 2);\n *\n * for (let i = 1; i <= 1_000_000; i++) {\n * pipe(\n * i,\n * incrementAfter,\n * doubleAfter,\n * toArray,\n * );\n * }\n * ```\n * @param f\n * @returns\n */\nconst doAfterFactory = (\n f: (v: TIn) => TOut | Promise,\n): {\n doAfter: (x: TIn | Promise) => TOut | Promise;\n asyncDoAfter: (promise: Promise) => Promise;\n syncDoAfter: (value: TIn) => TOut | Promise;\n} => {\n // let first = true;\n // let isAsync;\n const doAfterObj = {\n asyncDoAfter: async (valueOrPromise: Promise) =>\n f(await valueOrPromise),\n syncDoAfter: f,\n doAfter: (valueOrPromise: TIn | Promise) => {\n if (isPromise(valueOrPromise)) {\n doAfterObj.doAfter = doAfterObj.asyncDoAfter;\n } else {\n doAfterObj.doAfter = doAfterObj.syncDoAfter;\n }\n return doAfterObj.doAfter(valueOrPromise);\n },\n };\n return doAfterObj;\n // return (valueOrPromise: TIn | Promise) => {\n // if (first) {\n // isAsync = isPromise(valueOrPromise);\n // }\n // return isAsync ? (valueOrPromise as Promise).then(f) : f(valueOrPromise as TIn);\n // };\n};\n\n/**\n * This utility function will do a for loop, synchronously if all the parts are synchronous,\n * and asynchronously otherwise.\n * This should help us to use the same code yet supporting both possible scenarios.\n *\n * @param initialStateFactory\n * @param testBeforeEach\n * @param afterEach\n * @param codeToExecute\n * @returns void | Promise\n *\n * @category util\n */\nconst forLoop = (\n initialStateFactory: () => State | Promise,\n testBeforeEach: (a: State) => boolean | Promise,\n afterEach: (a: State) => State | Promise,\n codeToExecute: (a: State) => void | Promise,\n) => {\n // if we assume that thenable will return true as the second argument of the callbacks\n // when we are still synchronous, we can write this with thenable I think\n return thenable(initialStateFactory()).then((initialState, isSyncInit) => {\n return thenable(testBeforeEach(initialState)).then(\n (testResult, isSyncTest) => {\n // this should work, both for sync and async stuff, so that we don't get the indentation-of-hell issue?\n if (testResult) {\n return thenable(codeToExecute(initialState)).then((_, isSyncBody) => {\n return thenable(afterEach(initialState)).then(\n (firstStateAfterEach, isSyncAfterBody) => {\n if (isSyncInit && isSyncTest && isSyncBody && isSyncAfterBody) {\n // everything is synchronous so we can do a synchronous for loop\n let state = firstStateAfterEach;\n while (testBeforeEach(state)) {\n codeToExecute(state);\n state = afterEach(state);\n }\n return state;\n } else {\n // naive implementation: something is asynchronous so we can to do an asychronous for loop\n // return (async () => {\n // let state = firstStateAfterEach;\n // while (await testBeforeEach(state)) {\n // await codeToExecute(state);\n // state = await afterEach(state);\n // }\n // return state;\n // })();\n\n // await on a non-promise will still break execution and turns\n // the value into Promise.resolve(...))\n // SO can we only await if it's necessary?\n // 2^3 = 8 possible (ignoring the generation of initial state) combinations\n // with and without await\n // Luckily new Function('a', 'b', 'return a + b;'); will produce a function\n // from a string and some clever guy found a way to create an AsyncFunction\n // equivalent of that!\n // So using isSyncInit, isSyncTest, isSyncBody, isSyncAfterBody to decide\n // whether a value shouldbe awaited, we can solve it like this\n return new AsyncFunction(\n \"firstStateAfterEach\",\n \"testBeforeEach\",\n \"codeToExecute\",\n \"afterEach\",\n `\n let state = firstStateAfterEach;\n while (${isSyncTest ? \"\" : \"await \"}testBeforeEach(state)) {\n ${isSyncBody ? \"\" : \"await \"}codeToExecute(state);\n state = ${\n isSyncAfterBody ? \"\" : \"await \"\n }afterEach(state);\n }\n return state;\n `,\n )(\n firstStateAfterEach,\n testBeforeEach,\n codeToExecute,\n afterEach,\n );\n }\n },\n );\n });\n } else {\n return initialState;\n }\n },\n );\n });\n};\n\n// /**\n// * A more generic pipe function that takes multiple functions as input\n// * and outputs a single function where input = input of the first function\n// * and output = output where every funtion has been applied to the output of the previous on.\n// *\n// * So itr8Pipe(f1:(x:A)=>B, f2:(x:B)=>C, f3:(x:C)=>D) returns (a:A):D => f3(f2(f1(a)))\n// *\n// * @param first\n// * @param params\n// * @returns\n// *\n// * @deprecated see compose (and pipe)\n// */\n// function itr8Pipe(fn1: (x: A) => B): (x: A) => B;\n// function itr8Pipe(fn1: (x: A) => B, fn2: (x: B) => C): (x: A) => C;\n// function itr8Pipe(\n// fn1: (x: A) => B,\n// fn2: (x: B) => C,\n// fn3: (x: C) => D\n// ): (x: A) => D;\n// function itr8Pipe(\n// fn1: (x: A) => B,\n// fn2: (x: B) => C,\n// fn3: (x: C) => D,\n// fn4: (x: D) => E\n// ): (x: A) => E;\n// /*export*/ function itr8Pipe(\n// first: (x: A) => B,\n// ...params: Array<(any) => any>\n// ): any {\n// if (params.length === 0) {\n// return first;\n// } else {\n// return params.reduce<(any) => any>((acc, cur) => {\n// return (arg) => cur(acc(arg));\n// }, first);\n// }\n// }\n\n/**\n * A generic compose function that takes multiple functions as input\n * and outputs a single function where input = input of the first function\n * and output = output where every funtion has been applied to the output of the previous one.\n *\n * So\n * ```typescript\n * compose(f1:(x:A)=>B, f2:(x:B)=>C, f3:(x:C)=>D)\n * ```\n * will return a single unary function\n * ```typescript\n * (a:A):D => f3(f2(f1(a)))\n * ```\n *\n * @param first\n * @param params\n * @returns\n */\nfunction compose(fn1: (x: A) => B): (x: A) => B;\nfunction compose(fn1: (x: A) => B, fn2: (x: B) => C): (x: A) => C;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n): (x: A) => D;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n): (x: A) => E;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n): (x: A) => F;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n): (x: A) => G;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n): (x: A) => H;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn8: (x: G) => H,\n fn7: (x: H) => I,\n): (x: A) => I;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n fn8: (x: H) => I,\n fn9: (x: I) => J,\n): (x: A) => J;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n fn8: (x: H) => I,\n fn9: (x: I) => J,\n fn10: (x: J) => K,\n): (x: A) => K;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n fn8: (x: H) => I,\n fn9: (x: I) => J,\n fn10: (x: J) => K,\n ...moreFns: Array<(x: unknown) => unknown>\n): (x: A) => unknown;\nfunction compose(\n first: (x: A) => B,\n ...params: Array<(unknown) => unknown>\n): unknown {\n if (params.length === 0) {\n return first;\n } else {\n return params.reduce<(unknown) => unknown>((acc, cur) => {\n return (arg) => cur(acc(arg));\n }, first);\n }\n}\n\n/**\n * A pipe function applies the multiple functions to the first parameter\n *\n * So\n * ```typescript\n * pipe(x: A, f1:(x:A)=>B, f2:(x:B)=>C, f3:(x:C)=>D)\n * ```\n * returns the result of (a:A):D => f3(f2(f1(a)))\n *\n * @param first\n * @param params\n * @returns\n */\nfunction pipe(input: IN, fn1: (x: IN) => A): A;\nfunction pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B): B;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n): C;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n): D;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n): E;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n): F;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n): G;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n): H;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n fn9: (x: H) => I,\n): I;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n fn9: (x: H) => I,\n fn10: (x: I) => J,\n): J;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n fn9: (x: H) => I,\n fn10: (x: I) => J,\n ...moreFns: Array<(x: unknown) => unknown>\n): unknown;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n ...functionsToApply: Array<(unknown) => unknown>\n): unknown {\n if (functionsToApply.length === 0) {\n return fn1(input);\n } else {\n const composedFn = functionsToApply.reduce<(unknown) => unknown>(\n (acc, cur) => {\n return (arg) => cur(acc(arg));\n },\n fn1,\n );\n return composedFn(input);\n }\n}\n\nexport {\n compose,\n /**\n * @deprecated Use compose(...) instead!\n */\n compose as itr8Pipe,\n pipe,\n isPromise,\n AsyncFunction,\n thenable,\n thenableFactory,\n doAfter,\n doAfterFactory,\n forLoop,\n // itr8OperatorFactory,\n};\n", "/**\n * forEach is the one that will actually start 'draining' the iterator.\n * (itr8ToArray and most other itr8To... methods as well)\n *\n * @module\n */\n\nimport { isPromise } from \"../util/index.js\";\n\n/**\n * produces a function that can be applied to an iterator and that will execute\n * the handler on each value.\n *\n * The handler can be asynchronous!\n * By default the next will only be handled when the current handler has finished.\n * If you set options.concurrency to a higher value, you are allowing multiple handlers\n * to run in parallel.\n * But the next() will already be called while the (async) handler is still handling the current\n * result, which optimizes things by not waiting for the processing to finish, before asking for\n * the next one. Instead we'll first be asking for the next one, and then start processing of the\n * current one. This will waste less time than using 'for await (... of ...)' while still\n * processing things in the expected order!\n *\n * @param handler\n * @param options: ```{ concurrency: number }``` will control how many async handler are allowed to run in parallel. Default: 1\n * @returns\n *\n * @category interface/standard\n */\nconst forEach = function (\n handler: (T) => void | Promise,\n options?: { concurrency?: number },\n): (it: Iterator | AsyncIterator) => void | Promise {\n return (it: Iterator) => {\n let throwCount = 0;\n const maxRunningHandlers = options?.concurrency || 1;\n const runningHandlers: Set> = new Set();\n const waitForOpenSpot = async () => {\n // wait for an open spot if the max amount of running handlers is reached\n if (runningHandlers.size >= maxRunningHandlers) {\n await Promise.race(runningHandlers);\n }\n };\n const addToRunningHandlersList = (handlerPromise: Promise) => {\n // add it to the running handlers list\n runningHandlers.add(handlerPromise);\n handlerPromise.finally(() => {\n runningHandlers.delete(handlerPromise);\n });\n };\n /** Make sure the handler is wrapped in try/catch in order to send the right signals to the\n * input iterator in case something goes wrong!\n *\n * Self-replacing function, depending on the very first call, if the first call returns\n * a promise, the function wil replace itself with an async version, and with a sync\n * version otherwise\n */\n let tryHandler = (v: T): void | Promise => {\n const errorCatcher = (e) => {\n if (throwCount < 1) {\n try {\n it.throw?.(e);\n } catch (throwErr) {\n // native implementation crashes?\n // console.log(v, 'ERROR WHILE THROWING', throwErr);\n }\n throwCount += 1;\n }\n };\n\n try {\n const handlerPossiblePromise = handler(v);\n if (isPromise(handlerPossiblePromise)) {\n tryHandler = (v: T) => {\n // async tryHandler\n return (handler(v) as Promise).catch(errorCatcher);\n };\n handlerPossiblePromise.catch(errorCatcher);\n return handlerPossiblePromise;\n } else {\n tryHandler = (v: T) => {\n try {\n // sync tryHandler\n handler(v) as void;\n } catch (e) {\n errorCatcher(e);\n throw e;\n }\n };\n }\n } catch (e) {\n errorCatcher(e);\n throw e;\n }\n };\n\n const nextPromiseOrValue = it.next();\n if (isPromise(nextPromiseOrValue)) {\n const nextPromise = nextPromiseOrValue;\n\n const handleNext = async (nextValue) => {\n await waitForOpenSpot();\n\n const handlerPossiblePromise = tryHandler(nextValue);\n\n if (isPromise(handlerPossiblePromise)) {\n addToRunningHandlersList(handlerPossiblePromise);\n }\n };\n return (async () => {\n let next = (await nextPromise) as IteratorResult;\n while (!next.done) {\n await handleNext(next.value);\n next = await it.next();\n }\n // wait until all remaining handlers are done before resolving the current promise!\n await Promise.all(runningHandlers);\n it.return?.(next.value);\n })();\n } else {\n let next = nextPromiseOrValue;\n if (next.done) {\n it.return?.(next.value);\n } else {\n const handlerPossiblePromise: Promise | void = tryHandler(\n next.value,\n );\n if (isPromise(handlerPossiblePromise)) {\n return (async () => {\n let handlerPossiblePromiseIn: Promise | undefined =\n handlerPossiblePromise;\n while (!next.done) {\n const handlerPromise =\n handlerPossiblePromiseIn /* only the very first time */ ||\n (tryHandler(next.value) as Promise);\n handlerPossiblePromiseIn = undefined;\n\n addToRunningHandlersList(handlerPromise);\n\n next = it.next();\n await waitForOpenSpot();\n }\n // wait until all remaining handlers are done before resolving the current promise!\n await Promise.all(runningHandlers);\n it.return?.(next.value);\n })();\n } else {\n for (next = it.next(); !next.done; next = it.next()) {\n tryHandler(next.value);\n }\n // next = it.next();\n // while (!next.done) {\n // tryHandler(next.value);\n // next = it.next();\n // // console.log('[forEach] next', next);\n // }\n it.return?.(next.value);\n }\n }\n }\n };\n};\n\nexport { forEach };\n", "/**\n * Turns an array into an Iterator\n * (itr8FromIterable is more generic, this one is mainly useful for writing tests together\n * with its async brother itr8FromArrayAsync).\n *\n * @param a an array\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromArray(a: Array): IterableIterator {\n return a[Symbol.iterator]();\n}\n\nexport { itr8FromArray };\n", "/**\n * Turns an array into an (async) Iterator. Mainly useful for testing.\n *\n * @param a an array\n * @returns an async iterator\n *\n * @category interface/standard\n */\nfunction itr8FromArrayAsync(a: Array): AsyncIterableIterator {\n return (async function* () {\n for (const x of a) {\n yield x;\n }\n })();\n}\n\nexport { itr8FromArrayAsync };\n", "import { nextTick } from \"process\";\nimport { thenable } from \"../util/index.js\";\n\n/**\n * Turns a parameterless function into an Iterator that will produce results using\n * the input function's return value. In case the function returns a promise, the result will be\n * an AsyncIterator.\n * Useful for 'impure' stuff like Math.random, or Date.now etc.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromImpureFunction(Math.random),\n * take(3),\n * itr8ToArray\n * ); // => [0.2511072995514807, 0.04918679946517224, 0.48479881173432826]\n * ```\n * @param a anything like object, string, number, ...\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromImpureFunction(\n f: () => T | Promise,\n): IterableIterator | AsyncIterableIterator {\n const retVal = {\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n next: () => thenable(f()).then((value) => ({ done: false, value })).src,\n };\n return retVal;\n}\n\nexport { itr8FromImpureFunction };\n", "/**\n * Gets a wrapped instance of the iterator OR the async iterator from any iterable (including arrays)\n * so that we can easily pipe it into the operators.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromIterable([1,2,3]),\n * map((x) => x + 100),\n * )\n * ```\n *\n * @category interface/standard\n */\nfunction itr8FromIterable(\n it: Iterable | AsyncIterable,\n): IterableIterator | AsyncIterableIterator {\n if (it[Symbol.iterator]) {\n return it[Symbol.iterator]();\n } else {\n return it[Symbol.asyncIterator]();\n }\n}\n\nexport { itr8FromIterable };\n", "/**\n * Turns a single value into an Iterator that will produce 1 result.\n * Should work for boolean, number, string, object, ...\n *\n * @param a anything like object, string, number, ...\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromSingleValue(v: any): IterableIterator {\n return (function* () {\n yield v;\n })();\n}\n\nexport { itr8FromSingleValue };\n", "/**\n * Turns a single value into an (async) Iterator that will produce 1 result.\n * Should work for boolean, number, string, object, ...\n *\n * @param a anything like object, string, number, ...\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromSingleValueAsync(v: any): AsyncIterableIterator {\n return (async function* () {\n yield v;\n })();\n}\n\nexport { itr8FromSingleValueAsync };\n", "import { itr8FromIterable } from \"./itr8FromIterable.js\";\n\n/**\n * Turns a string into an Iterator that outputs every character of the string separately.\n *\n * (but since a string is an Iterable, you can use itr8FromIterable on strings as well!)\n *\n * @param s string\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromString(s: string): IterableIterator {\n return itr8FromIterable(s) as IterableIterator;\n}\n\nexport { itr8FromString };\n", "/**\n * Turns a string into an (async) Iterator that outputs every character of\n * the string separately.\n *\n * @param s a string\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromStringAsync(s: string): AsyncIterableIterator {\n return (async function* () {\n for (const x of s) {\n yield x;\n }\n })();\n}\n\nexport { itr8FromStringAsync };\n", "import { TPushable } from \"../types.js\";\n\n/**\n * Creates an AsyncIterableIterator, that also exposes\n * * a push(...) method that can be used to push values into it (for example based on events).\n * * a done() method that can be used to indicate that no more values will follow.\n *\n * The optional bufferSize parameter defines how large the buffer is that will hold the\n * messages until they are pulled by a next() call. The oldest messages will be\n * dropped if no one is consuming the iterator fast enough.\n *\n * If no bufferSize is specified, the buffer will keep growing indefinitely.\n *\n * @param observable\n * @returns\n *\n * @category interface/standard\n */\nfunction itr8Pushable(\n bufferSize?: number,\n): AsyncIterableIterator & TPushable {\n const buffer: any[] = [];\n\n let currentResolve;\n // let currentReject;\n let currentDataPromise;\n // let done = false;\n\n const createNewCurrentDataPromise = () => {\n currentDataPromise = new Promise((resolve /*, reject */) => {\n currentResolve = resolve;\n // currentReject = reject;\n });\n buffer.push(currentDataPromise);\n while (bufferSize !== undefined && buffer.length > bufferSize + 1) {\n // remove the oldest one from the buffer\n buffer.shift();\n }\n };\n\n createNewCurrentDataPromise();\n\n const retVal: AsyncIterableIterator & TPushable = {\n [Symbol.asyncIterator]: () => retVal,\n next: async () => {\n // if (done) {\n // return { done: true };\n // }\n if (buffer.length > 0) {\n // const [firstOfBufferPromise, ...restOfBuffer] = buffer;\n // buffer = restOfBuffer;\n const firstOfBufferPromise = buffer.shift();\n const asyncNext = await firstOfBufferPromise;\n return asyncNext;\n } else {\n throw new Error(\"[itr8FromObservable] No elements in the buffer?\");\n }\n },\n push: (value: T) => {\n currentResolve({ value });\n createNewCurrentDataPromise();\n },\n done: () => {\n currentResolve({ done: true });\n createNewCurrentDataPromise();\n // done = true;\n },\n };\n\n return retVal;\n}\n\nexport { itr8Pushable };\n", "import { TPushable } from \"../types.js\";\nimport { itr8Pushable } from \"./itr8Pushable.js\";\n\n/**\n * Returns a (pushable async) iterator that will automatically fire with the Date.now() value\n * of when it fired (= the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC).\n *\n * When you want it to stop, call the done() method of the returned iterator, and the interval\n * will be cleaned up.\n *\n * @param intervalMilliseconds\n * @returns an AsyncIterableIterator\n *\n * @category interface/standard\n */\nfunction itr8Interval(\n intervalMilliseconds: number,\n): AsyncIterableIterator & TPushable {\n const it = itr8Pushable(Infinity); // infinite buffer !!!\n const interval = setInterval(() => {\n it.push(Date.now());\n }, intervalMilliseconds);\n const origDone = it.done;\n it.done = () => {\n clearInterval(interval);\n return origDone();\n };\n return it;\n}\n\nexport { itr8Interval };\n", "/**\n * Utility function that produces an iterator producing numbers (not only integers)\n * starting and ending where you want, which is useful for trying out stuff\n * without manually having to create arrays.\n *\n * * 'from' can be higher than 'to', in which case the iterator will count down\n * * 'step' is always a positive number (but we are forgiving if it's not)\n *\n * @example\n * ```typescript\n * pipe(\n * itr8Range(0, 3)\n * itr8ToArray,\n * ) // => [0, 1, 2, 3]\n *\n * pipe(\n * itr8Range(0, 10, 3)\n * itr8ToArray,\n * ) // => [0, 3, 6, 9]\n *\n * pipe(\n * itr8Range(5, 1, 2)\n * itr8ToArray,\n * ) // => [5, 3, 1]\n * ```\n *\n * @param start start index\n * @param end end index\n * @param end step size, default = 1\n *\n * @category interface/standard\n */\nfunction itr8Range(\n from: number,\n to: number,\n step?: number,\n): IterableIterator {\n const stepValue = step !== undefined ? Math.abs(step) : 1;\n const upwards = from < to;\n return (function* () {\n if (upwards) {\n for (let i = from; i <= to; i = i + stepValue) {\n yield i;\n }\n } else {\n for (let i = from; i >= to; i = i - stepValue) {\n yield i;\n }\n }\n })();\n}\n\nexport { itr8Range };\n", "/**\n * Utility function that produces an (async) iterator\n * producing integers starting and ending where you want,\n * which is useful for trying out stuff without manually\n * having to create arrays.\n *\n * * 'from' can be higher than 'to', in which case the iterator will count down\n * * 'step' is always a positive number (but we are forgiving if it's not)\n *\n * @param start start index\n * @param end end index\n * @param end step size, default = 1\n *\n * @category interface/standard\n */\nfunction itr8RangeAsync(\n from: number,\n to: number,\n step?: number,\n): AsyncIterableIterator {\n const stepValue = step !== undefined ? Math.abs(step) : 1;\n const upwards = from < to;\n return (async function* () {\n if (upwards) {\n for (let i = from; i <= to; i = i + stepValue) {\n yield i;\n }\n } else {\n for (let i = from; i >= to; i = i - stepValue) {\n yield i;\n }\n }\n })();\n}\n\nexport { itr8RangeAsync };\n", "import { isPromise } from \"../util/index.js\";\n\n/**\n * Turns an itr8 into an array.\n *\n * @param iterator\n * @returns an array\n *\n * @category interface/standard\n */\nfunction itr8ToArray(\n iterator: Iterator | AsyncIterator,\n): Array | Promise> {\n let n = iterator.next();\n if (isPromise(n)) {\n return (async () => {\n const asyncResult: T[] = [];\n while (!(await n).done) {\n asyncResult.push((await n).value);\n n = iterator.next();\n }\n return asyncResult;\n })();\n } else {\n // return Array.from(iterator);\n const result: T[] = [];\n for (\n let nSync = n as IteratorResult;\n !nSync.done;\n nSync = iterator.next() as IteratorResult\n ) {\n result.push(nSync.value);\n }\n // let nSync = n as IteratorResult;\n // while (!nSync.done) {\n // result.push(nSync.value);\n // nSync = iterator.next() as IteratorResult;\n // }\n return result;\n }\n}\n\nexport { itr8ToArray };\n", "import { isPromise } from \"../util/index.js\";\n\n/**\n * Turns an itr8 into an object. It is like Object.fromEntries,\n * but it will work both for synchronous and asynchronous iterators\n *\n * @example\n * ```typescript\n * // synchronous, same as Object.fromEntries(...)\n * const myObj = pipe(\n * itr8FromIterable([['a', 'value of A'], ['b', 'value of B'], ['c', 'value of C']]),\n * itr8ToObject,\n * ) // => {\n * // a: 'value of A',\n * // b: 'value of B',\n * // c: 'value of C',\n * // }\n *\n * // asynchronous\n * await myObj2 = pipe(\n * itr8FromIterable([['a', 'value of A'], ['b', 'value of B'], ['c', 'value of C']]),\n * delay(100), // delay every element by 100 milliseconds\n * itr8ToObject,\n * ) // => {\n * // a: 'value of A',\n * // b: 'value of B',\n * // c: 'value of C',\n * // }\n * ```\n *\n * @param iterator\n * @returns an array\n *\n * @category interface/standard\n */\nfunction itr8ToObject(\n iterator:\n | Iterator<[TK: string | number | symbol, TV: unknown]>\n | AsyncIterator<[TK: string | number | symbol, TV: any]>,\n): Record | Promise> {\n let n = iterator.next();\n if (isPromise(n)) {\n return (async () => {\n const asyncResult: Record = {} as Record;\n while (!(await n).done) {\n const [k, v] = (await n).value;\n asyncResult[k] = v;\n n = iterator.next();\n }\n return asyncResult;\n })();\n } else {\n // return Array.from(iterator);\n const result: Record = {} as Record;\n let nSync = n as IteratorResult<[TK, TV]>;\n while (!nSync.done) {\n const [k, v] = nSync.value;\n result[k] = v;\n nSync = iterator.next() as IteratorResult<[TK, TV]>;\n }\n return result;\n }\n}\n\nexport { itr8ToObject };\n", "import { isPromise } from \"../util/index.js\";\nimport { forEach } from \"./forEach.js\";\n\n/**\n * Turns an iterator into a single string.\n * The strings will simply be 'glued' together, so if you need a separator,\n * use interperse first.\n *\n * It is the equivalent of Array.join('').\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray(['Hello', 'Goodbye']),\n * intersperse(' / '), // adds | between every 2 elements\n * itr8ToString,\n * ) // => 'Hello / Goodbye'\n *\n * const alphabet = pipe(\n * itr8Range(0, 25),\n * map((i: number) => String.fromCharCode(\"A\".charCodeAt(0) + i)),\n * itr8ToString\n * ); // => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n * ```\n *\n * @param iterator\n * @returns a string\n *\n * @category interface/standard\n */\nfunction itr8ToString(\n iterator: Iterator | AsyncIterator,\n): string | Promise {\n let n = iterator.next();\n if (isPromise(n)) {\n return (async () => {\n let asyncResult = \"\";\n while (!(await n).done) {\n asyncResult = asyncResult + (await n).value;\n n = iterator.next();\n }\n return asyncResult;\n })();\n } else {\n // return Array.from(iterator);\n let result = \"\";\n let nSync = n as IteratorResult;\n while (!nSync.done) {\n result = result + nSync.value;\n nSync = iterator.next() as IteratorResult;\n }\n return result;\n }\n}\n\nexport { itr8ToString };\n", "import { itr8FromIterable } from \"../../interface/index.js\";\nimport {\n TNextFnResult,\n TThenable,\n TTransIteratorSyncOrAsync,\n} from \"../../types.js\";\nimport {\n pipe,\n doAfter,\n forLoop,\n isPromise,\n thenable,\n thenableFactory,\n doAfterFactory,\n} from \"../../util/index.js\";\n\n/**\n * The powerMap can be used as the base for many many other operators.\n *\n * An operator is 'a function that generates a transIterator'.\n * So for example filter(...) is an operator, because when called with an argument\n * (the filter function) the result of that will be another function which is the transIterator.\n *\n * A transIterator is simply a function with an iterator as single argument which will return\n * another iterator. This way we can easily 'build a chain of mulitple transIterators'.\n * So it transforms iterators, which is why I have called it transIterator (~transducers).\n *\n * powerMap is an operator that generates a transIterator that\n * will work both on synchronous and asynchronous iterators.\n * The powerMap needs to be provided with a single function of the form:\n *\n * ```typescript\n * (nextOfPreviousIteratorInTheChain, state) => TNextFnResult | Promise<[TNextFnResult]>\n * ```\n * and another function generating an initial 'state' (not every operator needs state)\n *\n * * *nextIn* is the (resolved if async) result of a next call of the input iterator.\n * This means it will be of the form ```{ done: true }``` or ```{ done: false, value: <...> }```.\n * * The *state* parameter is used to allow operators to have state, but not all operators need this.\n * For example: a 'map' operator doesn't need state, but the 'skip' operator would need to keep\n * track of how many records have passed.\n *\n * Check the readme for some examples on how to write your own operators using 'powerMap'\n * (or check the source code as all the available operators have been built using this function).\n *\n * BEWARE: NEVER MODIFY THE STATE OBJECT (or any of its children!), ALWAYS RETURN A NEW VALUE!\n *\n * Why is the initial state not a simple value, but a function that produces the state?\n * This way, even if nextFn would modify the state, it wouldn't mess with other instances\n * of the same operator? Because if we'd like to deep clone the initial state ourselves, we might\n * end up with some complex cases when classes are involved (I hope no one who's interested in\n * this library will want to use classes as their state, because the library is more 'functional\n * programming' oriented)\n *\n * @typeParam TIn the type of values that the input iterator must produce\n * @typeParam TOut the type of values that the output iterator will produce\n * @typeParam TState the type of the state that will be passed between all iterations\n *\n * @param nextFn\n * @param initialStateFactory a function that generates the initialSate\n * @returns a function taking an iterator as input and that has an iterator as output\n *\n * @category operators/general\n */\nconst powerMap = function (\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n ) => TNextFnResult | Promise>,\n initialStateFactory: () => TState,\n): TTransIteratorSyncOrAsync {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n /** Means that we are done after this value or after finishing the currentOutputIterator */\n isLastOutputIterator: boolean;\n /** Means that we are done entirely */\n done: boolean;\n };\n\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n let nextInPromiseOrValue:\n | IteratorResult\n | Promise>\n | undefined = undefined;\n // let nextIn: IteratorResult | undefined = undefined;\n let isAsync: boolean | undefined = undefined;\n\n let isAsyncInput: boolean | undefined = undefined;\n function updateNextInPromiseOrValue() {\n nextInPromiseOrValue = itIn.next();\n if (isAsyncInput === undefined) {\n isAsyncInput = isPromise(nextInPromiseOrValue);\n isAsync = isAsync || isAsyncInput;\n }\n }\n let isAsyncNextFn: boolean | undefined = undefined;\n // let state = pState;\n\n // let currentOutputIterator: Iterator | AsyncIterator | undefined = undefined;\n let isAsyncCurrentOutputIterator: boolean | undefined = undefined;\n // let done = false;\n\n /**\n * Can/should we make this kind of recursive?\n * Figure out based on the input params whether we need to:\n * * return done because done = true\n * * return the next value of the current iterator\n * or empty the current iterator if we're at the end and call generateNextReturnVal\n * * do a call to nextFn\n * * if next = async, call generateNextReturnValAsync to handle this case\n * * set done to true if that is what it returns and call generateNextReturnVal\n * * return the value if it returns a value\n * * set current iterator if it returns an iterable and call generateNextReturnVal\n * @returns\n */\n const generateNextReturnValSync = ():\n | IteratorResult\n | Promise> => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n if (\n isAsyncCurrentOutputIterator ||\n isPromise(possibleNextValueOrPromise)\n ) {\n isAsyncCurrentOutputIterator = true;\n return generateNextReturnValAsync(\n true,\n undefined,\n possibleNextValueOrPromise,\n );\n }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n updateNextInPromiseOrValue();\n if (isAsyncInput) {\n return generateNextReturnValAsync(false);\n }\n const nextIn = nextInPromiseOrValue as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n ) as TNextFnResult;\n if (isAsyncNextFn === undefined) {\n isAsyncNextFn = isPromise(curNextFnResult);\n isAsync = isAsync || isAsyncNextFn;\n }\n if (isAsyncNextFn) {\n return generateNextReturnValAsync(false, curNextFnResult);\n }\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }\n };\n\n /**\n * Almost the same method but in case input or nextFn is async\n *\n * @param callUpdateNextInPromiseOrValue\n * @returns\n */\n const generateNextReturnValAsync = async (\n callUpdateNextInPromiseOrValue = true,\n nextFnResponse?,\n currentOutputIteratorNext?,\n ): Promise> => {\n let doUpdateNextInPromiseOrValue = callUpdateNextInPromiseOrValue;\n let alreadyKnownNextFnResponse = nextFnResponse;\n let alreadyKnownCurrentOutputIteratorNext = currentOutputIteratorNext;\n // while loop instead of calling this function recursively (call stack can become to large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n let possibleNextValueOrPromise;\n if (alreadyKnownCurrentOutputIteratorNext !== undefined) {\n possibleNextValueOrPromise = alreadyKnownCurrentOutputIteratorNext;\n alreadyKnownCurrentOutputIteratorNext = undefined; // only the first time !!!\n } else {\n possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n }\n const possibleNext = (\n isPromise(possibleNextValueOrPromise)\n ? await possibleNextValueOrPromise\n : possibleNextValueOrPromise\n ) as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to possibly call nextFn again\n if (doUpdateNextInPromiseOrValue) {\n updateNextInPromiseOrValue();\n } else {\n doUpdateNextInPromiseOrValue = true; // only possibly skip it the first time !!!\n }\n const nextIn = await nextInPromiseOrValue;\n let curNextFnResultPromiseOrValue;\n if (alreadyKnownNextFnResponse !== undefined) {\n curNextFnResultPromiseOrValue = alreadyKnownNextFnResponse;\n alreadyKnownNextFnResponse = undefined; // only use it the first time !!!\n } else {\n curNextFnResultPromiseOrValue = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n );\n }\n if (isAsyncNextFn === undefined) {\n isAsyncNextFn = isPromise(curNextFnResultPromiseOrValue);\n isAsync = isAsync || isAsyncNextFn;\n }\n const curNextFnResult = (\n isAsyncNextFn\n ? await curNextFnResultPromiseOrValue\n : curNextFnResultPromiseOrValue\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n operatorState.done = true; // make sure we keep returning done\n return { done: curNextFnResult.done, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n // return generateNextReturnValAsync();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n // return generateNextReturnValAsync();\n }\n }\n };\n\n /**\n * This method will replace itself with the right method once we know\n * in which case we are (sync, async)\n *\n * @returns {IteratorResult | Promise>}\n */\n let generateNextReturnVal = ():\n | IteratorResult\n | Promise> => {\n // VERSION without 'magic' for debugging\n return isAsync\n ? generateNextReturnValAsync()\n : generateNextReturnValSync();\n\n // VERSION that replaces generateNextReturnVal with the sync or async version\n // // if (isAsyncInput || isAsyncNextFn) {\n // // generateNextReturnVal = generateNextReturnValAsync;\n // // } else {\n // // generateNextReturnVal = generateNextReturnValSync;\n // // }\n\n // return generateNextReturnVal();\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const retVal = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: () => {\n if (isAsyncInput || isAsyncNextFn) {\n retVal.next = generateNextReturnValAsync;\n } else {\n retVal.next = generateNextReturnValSync;\n }\n return retVal.next();\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n itIn.return?.();\n return isAsyncInput || isAsyncNextFn\n ? Promise.resolve({ done: true, value })\n : { done: true, value };\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n itIn.throw?.(err);\n return isAsyncInput || isAsyncNextFn\n ? Promise.resolve({ done: true, value: undefined })\n : { done: true, value: undefined };\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n\n const transIt = (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n try {\n return operatorFunction(itIn, initialStateFactory());\n } catch (err) {\n itIn.throw?.();\n throw err;\n }\n };\n\n // let cachedValueThenable:\n // | ((x: any | Promise) => TThenable)\n // | undefined = undefined;\n\n /**\n * Experiment: we could expose the \"transNextFn\" which is similar to a transducer:\n * it is a function that transforms an existing nextFn, and by linking them all together\n * we'll get a nextFn that combines multiple oeprations meaning we only need one 'intermediate'\n * iterator. This might be more performant.\n * But that can only be done if input and output match so they can be composed.\n *\n * So instead of getting (nextIn, state, params) as input (without the state) and\n * TNextFnResult as output (without the state as well) we could create a function that\n * gets TNextFnResult as input as well (or at least a subset of all the possibilities).\n *\n * By subset I mean: maybe only when they have a value or an iterable, and not when they\n * have no value (meaning the element is skipped).\n */\n transIt.transNextFn = (\n input: TNextFnResult,\n ): TNextFnResult => {\n const operatorState: TOperatorState = {\n state: initialStateFactory(),\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n if (input.done === true) {\n return input;\n } else if (/* input.done === false && */ \"iterable\" in input) {\n const iterator =\n input.iterable[Symbol.iterator] || input.iterable[Symbol.asyncIterator];\n const iterable: TOut[] = [];\n const f = forLoop(\n () => iterator.next(),\n (n) => n.done !== true,\n (n) => iterator.next(),\n (nextIn: IteratorResult) => {\n thenable(\n nextFn(nextIn as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n // store the new state\n operatorState.state = curNextFnResult.state;\n\n // if it contains an iterable => iterate over it, otherwise add the value to the output array\n if (curNextFnResult.done === false && curNextFnResult.iterable) {\n // TODO support async iterable !!!\n iterable.push(...curNextFnResult.iterable);\n } else {\n iterable.push(curNextFnResult.value);\n }\n }).src;\n },\n );\n return thenable(f).then((_forLoopResult) => {\n return { done: false, iterable };\n }).src;\n } else if (/* input.done === false && */ \"value\" in input) {\n // if (cachedValueThenable === undefined) {\n // cachedValueThenable = thenableFactory(input);\n // }\n // return cachedValueThenable(input)\n // .then((input) =>\n return thenable(\n nextFn(input as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n const { newState, ...retVal } = curNextFnResult;\n // store the new state\n operatorState.state = curNextFnResult.state;\n return retVal;\n }).src;\n } else {\n // no value nor iterable in input, meaning this element should be skipped\n // so don't call any other transformers on this element\n return input;\n }\n };\n\n return transIt;\n};\n\n/**\n * An experimental version of powerMap using doAfterFactory\n * (which is proven to be faster than thenable).\n * It seems slightly faster than powerMap for synchronous code, but is slower for async.\n *\n * The most important optimization is probably the same as what doAfterFactory does:\n * do a first run in order to figure out whether the first next() call is synchronous\n * and then replace the next function by an entirely synchronous version.\n * (And maybe the async version can be written with doAfterFactory (or a for-loop))\n *\n * Consequence: an iterable can only be async in a synchronous handler if it is used the first time\n * otherwise the iterator will already be synchronous.\n *\n * how do you make the while loop work for both synchronous and asynchronous code?\n * MAYBE I should reimplement the forLoop function using doAfter, and then use the powerMap version\n * that is written using the for-loop (and drop this one)?\n *\n * @param nextFn\n * @param initialStateFactory\n * @returns\n */\nconst powerMapWithDoAfter = function <\n TIn = unknown,\n TOut = unknown,\n TState = void,\n>(\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n ) => TNextFnResult | Promise>,\n initialStateFactory: () => TState,\n): TTransIteratorSyncOrAsync {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n /** Means that we are done after this value or after finishing the currentOutputIterator */\n isLastOutputIterator: boolean;\n /** Means that we are done entirely */\n done: boolean;\n };\n\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n let nextInPromiseOrValue:\n | IteratorResult\n | Promise>\n | undefined = undefined;\n\n /**\n * This very first scroll through the loop should give us all the info we need\n * in order to establish whether the iterator will be synchronous or asynchronous.\n *\n * After this first call, we can then overwrite the next function with either a sync\n * or an async version.\n * @returns\n */\n const generateFirstReturnValIfPossible = ():\n | IteratorResult\n | Promise>\n | null\n | Promise => {\n return pipe(\n itIn.next(),\n doAfter((nextIn) => nextFn(nextIn, operatorState.state)),\n doAfter((curNextFnResult) => {\n if (\n \"state\" in curNextFnResult &&\n curNextFnResult.state !== undefined\n ) {\n operatorState.state = curNextFnResult.state;\n }\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined } as IteratorResult;\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return {\n done: false,\n value: curNextFnResult.value,\n } as IteratorResult;\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined) {\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n }\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n return pipe(\n operatorState.currentOutputIterator.next(),\n doAfter(\n (currentOutputIteratorNext): IteratorResult | null =>\n currentOutputIteratorNext.done\n ? null\n : currentOutputIteratorNext,\n ),\n );\n } else {\n return null;\n }\n }),\n ) as\n | IteratorResult\n | null\n | Promise>\n | Promise;\n };\n\n const generateNextReturnValSync = ():\n | IteratorResult\n | Promise> => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNext =\n operatorState.currentOutputIterator.next() as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = itIn.next() as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }\n };\n\n const doAfters = {\n /**\n * This one handles when we have a current output iterator that is not done.\n * It will generate the next value\n */\n currentOutputIteratorNextToNextOut: doAfterFactory<\n IteratorResult,\n IteratorResult | undefined\n >((possibleNext): IteratorResult | undefined => {\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }),\n /**\n * This will apply curNextFn to curNextIn\n */\n applyCurNextFnToNextIn: doAfterFactory<\n IteratorResult,\n TNextFnResult | Promise>\n >(\n (nextIn) =>\n nextFn(nextIn, operatorState.state) as TNextFnResult,\n ),\n /**\n * This part will turn the result of applying nextFn to nextIn into\n * an IteratorResult (or undefined if we need to go back to the top of\n * the while loop\n */\n handleNextFnResult: doAfterFactory<\n TNextFnResult,\n IteratorResult | undefined\n >((curNextFnResult) => {\n if (\"state\" in curNextFnResult) {\n operatorState.state = curNextFnResult.state as TState;\n }\n\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }),\n };\n const generateNextReturnValAsync = async (): Promise<\n IteratorResult\n > => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNext = pipe(\n operatorState.currentOutputIterator.next(),\n doAfters.currentOutputIteratorNextToNextOut.doAfter,\n );\n if ((await possibleNext) !== undefined) {\n return possibleNext as\n | IteratorResult\n | Promise>;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const possibleNext = pipe(\n itIn.next(),\n doAfters.applyCurNextFnToNextIn.doAfter,\n doAfters.handleNextFnResult.doAfter,\n );\n if ((await possibleNext) !== undefined) {\n // (async () => console.log(\"Return possibleNext:\", await possibleNext))();\n return possibleNext as\n | IteratorResult\n | Promise>;\n }\n // if return has not been called, return to the top of the while loop again\n }\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const retVal = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: () => {\n const n = generateFirstReturnValIfPossible();\n const async = isPromise(n);\n if (isPromise(n)) {\n // const array = [];\n retVal.next = generateNextReturnValAsync;\n // async () => {\n // const n = await generateNextReturnValAsync();\n // if (!n) {\n // console.log(\"ASYNC next:\", n);\n // console.log(array);\n\n // console.log(\n // new Error(\"generateNextReturnValAsync returns undefined\")\n // .stack,\n // );\n // }\n // return n;\n // }\n return n.then((n2) => (n2 !== null ? n2 : retVal.next()));\n } else {\n retVal.next = generateNextReturnValSync;\n return n !== null ? n : retVal.next();\n }\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n itIn.return?.();\n return retVal.next === generateNextReturnValSync\n ? { done: true, value }\n : Promise.resolve({ done: true, value });\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n itIn.throw?.(err);\n return retVal.next === generateNextReturnValSync\n ? { done: true, value: undefined }\n : Promise.resolve({ done: true, value: undefined });\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n\n const transIt = (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n try {\n return operatorFunction(itIn, initialStateFactory());\n } catch (err) {\n itIn.throw?.();\n throw err;\n }\n };\n\n // let cachedValueThenable:\n // | ((x: any | Promise) => TThenable)\n // | undefined = undefined;\n\n /**\n * Experiment: we could expose the \"transNextFn\" which is similar to a transducer:\n * it is a function that transforms an existing nextFn, and by linking them all together\n * we'll get a nextFn that combines multiple oeprations meaning we only need one 'intermediate'\n * iterator. This might be more performant.\n * But that can only be done if input and output match so they can be composed.\n *\n * So instead of getting (nextIn, state, params) as input (without the state) and\n * TNextFnResult as output (without the state as well) we could create a function that\n * gets TNextFnResult as input as well (or at least a subset of all the possibilities).\n *\n * By subset I mean: maybe only when they have a value or an iterable, and not when they\n * have no value (meaning the element is skipped).\n */\n transIt.transNextFn = (\n input: TNextFnResult,\n ): TNextFnResult => {\n const operatorState: TOperatorState = {\n state: initialStateFactory(),\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n if (input.done === true) {\n return input;\n } else if (/* input.done === false && */ \"iterable\" in input) {\n const iterator =\n input.iterable[Symbol.iterator] || input.iterable[Symbol.asyncIterator];\n const iterable: TOut[] = [];\n const f = forLoop(\n () => iterator.next(),\n (n) => n.done !== true,\n (n) => iterator.next(),\n (nextIn: IteratorResult) => {\n thenable(\n nextFn(nextIn as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n // store the new state\n operatorState.state = curNextFnResult.state;\n\n // if it contains an iterable => iterate over it, otherwise add the value to the output array\n if (curNextFnResult.done === false && curNextFnResult.iterable) {\n // TODO support async iterable !!!\n iterable.push(...curNextFnResult.iterable);\n } else {\n iterable.push(curNextFnResult.value);\n }\n }).src;\n },\n );\n return thenable(f).then((_forLoopResult) => {\n return { done: false, iterable };\n }).src;\n } else if (/* input.done === false && */ \"value\" in input) {\n // if (cachedValueThenable === undefined) {\n // cachedValueThenable = thenableFactory(input);\n // }\n // return cachedValueThenable(input)\n // .then((input) =>\n return thenable(\n nextFn(input as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n const { newState, ...retVal } = curNextFnResult;\n // store the new state\n operatorState.state = curNextFnResult.state;\n return retVal;\n }).src;\n } else {\n // no value nor iterable in input, meaning this element should be skipped\n // so don't call any other transformers on this element\n return input;\n }\n };\n\n return transIt;\n};\n\n/**\n * An experimental version of powerMap trying to learn from the lessons from\n * the powerMapWithDoAfter version\n * We'll remove doAfter again from the async version, and use simple ifs again.\n *\n * The most important optimization is probably the same as what doAfterFactory does:\n * do a first run in order to figure out whether the first next() call is synchronous\n * and then replace the next function by an entirely synchronous version.\n * (And maybe the async version can be written with doAfterFactory (or a for-loop))\n *\n * Consequence: an iterable can only be async in a synchronous handler if it is used the first time\n * otherwise the iterator will already be synchronous.\n *\n * how do you make the while loop work for both synchronous and asynchronous code?\n * MAYBE I should reimplement the forLoop function using doAfter, and then use the powerMap version\n * that is written using the for-loop (and drop this one)?\n *\n * @param nextFn\n * @param initialStateFactory\n * @returns\n */\nconst powerMapWithoutDoAfter = function <\n TIn = unknown,\n TOut = unknown,\n TState = void,\n>(\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n ) => TNextFnResult | Promise>,\n initialStateFactory: () => TState,\n): TTransIteratorSyncOrAsync {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n /** Means that we are done after this value or after finishing the currentOutputIterator */\n isLastOutputIterator: boolean;\n /** Means that we are done entirely */\n // done: boolean;\n };\n\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n // done: false,\n };\n\n /**\n * This very first scroll through the loop should give us all the info we need\n * in order to establish whether the iterator will be synchronous or asynchronous.\n *\n * After this first call, we can then overwrite the next function with either a sync\n * or an async version.\n * @returns\n */\n const generateFirstReturnValIfPossible = ():\n | IteratorResult\n | Promise>\n | null\n | Promise => {\n return pipe(\n itIn.next(),\n doAfter((nextIn) => nextFn(nextIn, operatorState.state)),\n doAfter((curNextFnResult) => {\n if (\n \"state\" in curNextFnResult &&\n curNextFnResult.state !== undefined\n ) {\n operatorState.state = curNextFnResult.state;\n }\n if (curNextFnResult.done) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n return { done: true, value: undefined } as IteratorResult;\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n }\n return {\n done: false,\n value: curNextFnResult.value,\n } as IteratorResult;\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined) {\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n }\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n return pipe(\n operatorState.currentOutputIterator.next(),\n doAfter(\n (currentOutputIteratorNext): IteratorResult | null => {\n if (currentOutputIteratorNext.done) {\n operatorState.currentOutputIterator = undefined;\n return null;\n } else {\n // Don't set it here...\n // returnedIterator.next = generateNextFromOutputIteratorAsync;\n return currentOutputIteratorNext;\n }\n },\n ),\n );\n } else {\n return null;\n }\n }),\n ) as\n | IteratorResult\n | null\n | Promise>\n | Promise;\n };\n\n const generateDoneSync: () => IteratorResult = () => ({\n done: true,\n value: undefined,\n });\n const generateNextFromOutputIteratorSync: () => IteratorResult =\n () => {\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n const possibleNext = (\n operatorState.currentOutputIterator as Iterator\n ).next() as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n return { done: true, value: undefined };\n } else {\n returnedIterator.next = generateNextReturnValSync;\n return returnedIterator.next();\n }\n } else {\n return possibleNext;\n }\n };\n\n const generateNextReturnValSync = ():\n | IteratorResult\n | Promise> => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // no running iterator, so we need to call nextFn again\n const curNextFnResult = nextFn(\n itIn.next() as IteratorResult,\n operatorState.state,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult) {\n operatorState.state = curNextFnResult.state as TState;\n }\n\n if (curNextFnResult.done) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n returnedIterator.next = generateNextFromOutputIteratorSync;\n return returnedIterator.next();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }\n };\n\n let outputIteratorIsAsync: boolean | undefined = undefined;\n let inputIteratorIsAsync: boolean | undefined = undefined;\n let nextFnIsAsync: boolean | undefined = undefined;\n\n const generateDoneAsync: () => Promise<\n IteratorResult\n > = async () => ({\n done: true,\n value: undefined,\n });\n const generateNextFromOutputIteratorAsync: () => Promise<\n IteratorResult\n > = async () => {\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n if (outputIteratorIsAsync === undefined)\n outputIteratorIsAsync = isPromise(possibleNextValueOrPromise);\n const possibleNext = (\n outputIteratorIsAsync\n ? await possibleNextValueOrPromise\n : possibleNextValueOrPromise\n ) as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n returnedIterator.next = generateDoneAsync; // operatorState.done = true;\n return { done: true, value: undefined };\n } else {\n returnedIterator.next = generateNextReturnValAsync;\n return returnedIterator.next();\n }\n } else {\n return possibleNext;\n }\n }\n };\n\n const generateNextReturnValAsync = async (): Promise<\n IteratorResult\n > => {\n // while loop instead of calling this function recursively (call stack can become to large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // no running iterator, so we need to possibly call nextFn again\n const nextInPromiseOrValue = itIn.next();\n if (inputIteratorIsAsync === undefined)\n inputIteratorIsAsync = isPromise(nextInPromiseOrValue);\n const nextIn = inputIteratorIsAsync\n ? await nextInPromiseOrValue\n : nextInPromiseOrValue;\n const curNextFnResultPromiseOrValue = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n );\n if (nextFnIsAsync === undefined)\n nextFnIsAsync = isPromise(curNextFnResultPromiseOrValue);\n\n const curNextFnResult = (\n nextFnIsAsync\n ? await curNextFnResultPromiseOrValue\n : curNextFnResultPromiseOrValue\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n // make sure we keep returning done\n returnedIterator.next = generateDoneAsync; // operatorState.done = true;\n return { done: curNextFnResult.done, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n returnedIterator.next = generateDoneAsync; // operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n returnedIterator.next = generateNextFromOutputIteratorAsync;\n return returnedIterator.next();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n // return generateNextReturnValAsync();\n }\n }\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const returnedIterator = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => returnedIterator,\n [Symbol.asyncIterator]: () => returnedIterator,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: () => {\n const n = generateFirstReturnValIfPossible();\n if (isPromise(n)) {\n return (async () => {\n // make sure all is handled before we decide what the next() function will become\n const nResolved = await n;\n returnedIterator.next =\n operatorState.currentOutputIterator === undefined\n ? generateNextReturnValAsync\n : generateNextFromOutputIteratorAsync;\n return nResolved !== null ? nResolved : returnedIterator.next();\n })();\n } else {\n returnedIterator.next =\n operatorState.currentOutputIterator === undefined\n ? generateNextReturnValSync\n : generateNextFromOutputIteratorSync;\n return n !== null ? n : returnedIterator.next();\n }\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n itIn.return?.();\n return returnedIterator.next === generateNextReturnValSync\n ? { done: true, value }\n : Promise.resolve({ done: true, value });\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n itIn.throw?.(err);\n return returnedIterator.next === generateNextReturnValSync\n ? { done: true, value: undefined }\n : Promise.resolve({ done: true, value: undefined });\n },\n };\n\n return returnedIterator as\n | IterableIterator\n | AsyncIterableIterator;\n };\n\n const transIt = (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n try {\n return operatorFunction(itIn, initialStateFactory());\n } catch (err) {\n itIn.throw?.();\n throw err;\n }\n };\n\n // let cachedValueThenable:\n // | ((x: any | Promise) => TThenable)\n // | undefined = undefined;\n\n /**\n * Experiment: we could expose the \"transNextFn\" which is similar to a transducer:\n * it is a function that transforms an existing nextFn, and by linking them all together\n * we'll get a nextFn that combines multiple oeprations meaning we only need one 'intermediate'\n * iterator. This might be more performant.\n * But that can only be done if input and output match so they can be composed.\n *\n * So instead of getting (nextIn, state, params) as input (without the state) and\n * TNextFnResult as output (without the state as well) we could create a function that\n * gets TNextFnResult as input as well (or at least a subset of all the possibilities).\n *\n * By subset I mean: maybe only when they have a value or an iterable, and not when they\n * have no value (meaning the element is skipped).\n */\n transIt.transNextFn = (\n input: TNextFnResult,\n ): TNextFnResult => {\n const operatorState: TOperatorState = {\n state: initialStateFactory(),\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n // done: false,\n };\n\n if (input.done === true) {\n return input;\n } else if (/* input.done === false && */ \"iterable\" in input) {\n const iterator =\n input.iterable[Symbol.iterator] || input.iterable[Symbol.asyncIterator];\n const iterable: TOut[] = [];\n const f = forLoop(\n () => iterator.next(),\n (n) => n.done !== true,\n (n) => iterator.next(),\n (nextIn: IteratorResult) => {\n thenable(\n nextFn(nextIn as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n // store the new state\n operatorState.state = curNextFnResult.state;\n\n // if it contains an iterable => iterate over it, otherwise add the value to the output array\n if (curNextFnResult.done === false && curNextFnResult.iterable) {\n // TODO support async iterable !!!\n iterable.push(...curNextFnResult.iterable);\n } else {\n iterable.push(curNextFnResult.value);\n }\n }).src;\n },\n );\n return thenable(f).then((_forLoopResult) => {\n return { done: false, iterable };\n }).src;\n } else if (/* input.done === false && */ \"value\" in input) {\n // if (cachedValueThenable === undefined) {\n // cachedValueThenable = thenableFactory(input);\n // }\n // return cachedValueThenable(input)\n // .then((input) =>\n return thenable(\n nextFn(input as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n const { newState, ...retVal } = curNextFnResult;\n // store the new state\n operatorState.state = curNextFnResult.state;\n return retVal;\n }).src;\n } else {\n // no value nor iterable in input, meaning this element should be skipped\n // so don't call any other transformers on this element\n return input;\n }\n };\n\n return transIt;\n};\n\n/**\n * EXPERIMENTAL VERSION OF THIS FUNCTION written with forLoop and thenable, which might be easier\n * to read or maintain, and could be faster...\n *\n * An operator is 'a function that generates a transIterator'.\n * So for example filter(...) is an operator, because when called with an argument\n * (the filter function) the result of that will be another function which is the transIterator.\n *\n * A transIterator is simply a function with an iterator as single argument which will return\n * another iterator. This way we can easily 'build a chain of mulitple transIterators'.\n * So it transforms iterators, which is why I have called it transIterator (~transducers).\n *\n * powerMap is a function that generates a transIteratorthat\n * will work both on synchronous and asynchronous iterators.\n * The factory needs to be provided with a single function of the form:\n *\n * ```typescript\n * (nextOfPreviousIteratorInTheChain, state) => TNextFnResult | Promise<[TNextFnResult]>\n * ```\n * and an initial state\n *\n * * nextOfPreviousIteratorInTheChain is the (resolved if async) result of a next call of the input\n * iterator. This means it will be of the form { done: true } or { done: false, value: <...> }.\n * * The state parameter is used to allow operators to have state, but not all operators need this.\n * For example: a 'map' operator doesn't need state, but the 'skip' operator would need to keep\n * track of how many records have passed.\n * * The operator params are the argument that is given to the operator function, like a number for\n * a 'take' operator, or the filter function for a 'filter' operator.\n *\n * Check the readme for some examples on how to write your own operators with powerMap\n * (or check the source code as all the available operators have been built using this function).\n *\n * BEWARE: NEVER MODIFY THE STATE OBJECT (or any of its children!), ALWAYS RETURN A NEW VALUE!\n *\n * QUESTION: would it be better to have an initial state producing function instead of an initial\n * state?\n * This way, even if nextFn would modify the state, it wouldn't mess with other instances\n * of the same operator? Because if we'd like to deep clone the initial state ourselves, we might\n * end up with some complex cases when classes are involved (I hope no one who's interested in\n * this library will want to use classes in their state, because the library is more 'functional\n * programming' oriented)\n *\n * @param nextFn\n * @param initialStateFactory a function that generates the initialSate\n * @returns a funtion taking an iterator (and optionally some argument) as input and that has an iterator as output\n *\n * @category util\n */\n// const itr8OperatorFactoryWithForLoop = function (\n// nextFn: (nextIn: IteratorResult, state: any, params: any) =>\n// TNextFnResult | Promise>,\n// initialStateFactory: () => TState,\n// ): (params: TParams) => TTransIteratorSyncOrAsync {\n// return function (params: TParams): TTransIteratorSyncOrAsync {\n// const operatorFunction = (itIn: Iterator | AsyncIterator, pState: TState) => {\n// type TOperatorFactoryState = {\n// state:TState,\n// currentOutputIterator:Iterator | AsyncIterator | undefined,\n// done:boolean,\n// };\n\n// const operatorFactoryState:TOperatorFactoryState = {\n// state: pState,\n// currentOutputIterator: undefined,\n// done: false,\n// };\n// // let nextInPromiseOrValue: IteratorResult | Promise> | undefined = undefined;\n// // // let nextIn: IteratorResult | undefined = undefined;\n// // let isAsyncInput: boolean | undefined = undefined;\n// // function updateNextInPromiseOrValue() {\n// // nextInPromiseOrValue = itIn.next();\n// // if (isAsyncInput === undefined) isAsyncInput = isPromise(nextInPromiseOrValue);\n// // }\n// // let isAsyncNextFn: boolean | undefined = undefined;\n// // // let state = pState !== undefined ? pState : initialState;\n// // let state = pState;\n\n// // let currentOutputIterator: Iterator | AsyncIterator | undefined = undefined;\n// // // let isAsyncCurrentOutputIterator:boolean | undefined = undefined;\n// // let done = false;\n\n// /**\n// * Can/should we make this kind of recursive?\n// * Figure out based on the input params whether we need to:\n// * * return done because done = true\n// * * return the next value of the current iterator\n// * or empty the current iterator if we're at the end and call generateNextReturnVal\n// * * do a call to nextFn\n// * * if next = async, call generateNextReturnValAsync to handle this case\n// * * set done to true if that is what it returns and call generateNextReturnVal\n// * * return the value if it returns a value\n// * * set current iterator if it returns an iterable and call generateNextReturnVal\n// * @returns\n// */\n// const generateNextReturnVal = () => {\n\n// forLoop| undefined }>(\n// () => (operatorFactoryState),\n// ({next}) => next !== undefined,\n// (state) => {\n// if (state.done) {\n// return { value: undefined, done: true };\n// }\n// // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n// if (state.currentOutputIterator !== undefined) {\n// return thenable(state.currentOutputIterator.next())\n// .then((v) => {\n\n// })\n// if (isPromise(possibleNextValueOrPromise)) {\n// return generateNextReturnValAsync(true, undefined, possibleNextValueOrPromise);\n// }\n// const possibleNext = possibleNextValueOrPromise as IteratorResult;\n\n// if (possibleNext.done) {\n// currentOutputIterator = undefined;\n// } else {\n// return possibleNext;\n// }\n// }\n\n// return state;\n// },\n// () => {}\n// );\n// // while loop instead of calling this function recursively (call stack can become too large)\n// while (true) {\n// if (done) {\n// return { value: undefined, done: true };\n// }\n// // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n// if (currentOutputIterator) {\n// const possibleNextValueOrPromise = currentOutputIterator.next();\n// if (isPromise(possibleNextValueOrPromise)) {\n// return generateNextReturnValAsync(true, undefined, possibleNextValueOrPromise);\n// }\n// const possibleNext = possibleNextValueOrPromise as IteratorResult;\n\n// if (possibleNext.done) {\n// currentOutputIterator = undefined;\n// } else {\n// return possibleNext;\n// }\n// }\n\n// // no running iterator, so we need to call nextFn again\n// updateNextInPromiseOrValue();\n// if (isAsyncInput) {\n// return generateNextReturnValAsync(false);\n// }\n// const nextIn = nextInPromiseOrValue as IteratorResult;\n// const curNextFnResult = nextFn(nextIn as IteratorResult, state, params) as TNextFnResult;\n// if (isAsyncNextFn === undefined) isAsyncNextFn = isPromise(curNextFnResult);\n// if (isAsyncNextFn) {\n// return generateNextReturnValAsync(false, curNextFnResult);\n// }\n// if ('state' in curNextFnResult) state = curNextFnResult.state as TState;\n\n// if (curNextFnResult.done) {\n// done = true;\n// // return generateNextReturnVal();\n// } else if ('value' in curNextFnResult) {\n// return { done: false, value: curNextFnResult.value };\n// } else if ('iterable' in curNextFnResult) {\n// if (currentOutputIterator !== undefined) throw new Error('currentOutputIterator should be undefined at this point');\n// currentOutputIterator = itr8FromIterable(curNextFnResult.iterable);\n// if (currentOutputIterator?.next === undefined) {\n// throw new Error('Error while trying to get output iterator, did you specify something that is not an Iterable to the \\'iterable\\' property? (when using a generator function, don\\'t forget to call it in order to return an IterableIterator!)');\n// }\n// // goto next round of while loop\n// // return generateNextReturnVal();\n// } else {\n// // we need to call nextIn again\n\n// // goto next round of while loop\n// // return generateNextReturnVal();\n// }\n// }\n// };\n\n// /**\n// * Almost the same method but in case input or nextFn is async\n// *\n// * @param callUpdateNextInPromiseOrValue\n// * @returns\n// */\n// const generateNextReturnValAsync = async (callUpdateNextInPromiseOrValue = true, nextFnResponse?, currentOutputIteratorNext?) => {\n// let doUpdateNextInPromiseOrValue = callUpdateNextInPromiseOrValue;\n// let alreadyKnownNextFnResponse = nextFnResponse;\n// let alreadyKnownCurrentOutputIteratorNext = currentOutputIteratorNext;\n// // while loop instead of calling this function recursively (call stack can become to large)\n// while (true) {\n// if (done) {\n// return { value: undefined, done: true };\n// }\n// // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n// if (currentOutputIterator) {\n// let possibleNextValueOrPromise;\n// if (alreadyKnownCurrentOutputIteratorNext !== undefined) {\n// possibleNextValueOrPromise = alreadyKnownCurrentOutputIteratorNext;\n// alreadyKnownCurrentOutputIteratorNext = undefined; // only the first time !!!\n// } else {\n// possibleNextValueOrPromise = currentOutputIterator.next() as any;\n// }\n// const possibleNext = (\n// isPromise(possibleNextValueOrPromise)\n// ? await possibleNextValueOrPromise\n// : possibleNextValueOrPromise\n// ) as IteratorResult;\n\n// if (possibleNext.done) {\n// currentOutputIterator = undefined;\n// } else {\n// return possibleNext;\n// }\n// }\n\n// // no running iterator, so we need to possibly call nextFn again\n// if (doUpdateNextInPromiseOrValue) {\n// updateNextInPromiseOrValue();\n// } else {\n// doUpdateNextInPromiseOrValue = true; // only possibly skip it the first time !!!\n// };\n// const nextIn = await nextInPromiseOrValue;\n// let curNextFnResultPromiseOrValue;\n// if (alreadyKnownNextFnResponse !== undefined) {\n// curNextFnResultPromiseOrValue = alreadyKnownNextFnResponse;\n// alreadyKnownNextFnResponse = undefined; // only use it the first time !!!\n// } else {\n// curNextFnResultPromiseOrValue = nextFn(nextIn as IteratorResult, state, params);\n// }\n// if (isAsyncNextFn === undefined) isAsyncNextFn = isPromise(curNextFnResultPromiseOrValue);\n// const curNextFnResult = (isAsyncNextFn ? await curNextFnResultPromiseOrValue : curNextFnResultPromiseOrValue) as TNextFnResult;\n// if ('state' in curNextFnResult) state = curNextFnResult.state as TState;\n\n// if (curNextFnResult.done) {\n// done = true;\n// // goto next round of while loop\n// // return generateNextReturnValAsync();\n// } else if ('value' in curNextFnResult) {\n// return { done: false, value: curNextFnResult.value };\n// } else if ('iterable' in curNextFnResult) {\n// if (currentOutputIterator !== undefined) throw new Error('currentOutputIterator should be undefined at this point');\n// currentOutputIterator = itr8FromIterable(curNextFnResult.iterable);\n// if (currentOutputIterator?.next === undefined) {\n// throw new Error('Error while trying to get output iterator, did you specify something that is not an Iterable to the \\'iterable\\' property? (when using a generator function, don\\'t forget to call it in order to return an IterableIterator!)');\n// }\n// // goto next round of while loop\n// // return generateNextReturnValAsync();\n// } else {\n// // we need to call nextIn again\n\n// // goto next round of while loop\n// // return generateNextReturnValAsync();\n// }\n// }\n// };\n\n// ////////////////////////////////////////////////////////////////////////////////\n// // Here is the returned IterableIterator\n// ////////////////////////////////////////////////////////////////////////////////\n// const retVal = {\n// // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n// // since we can only know whether the output will be sync or async after the first next call,\n// // we'll expose both iterator and asynciterator functions...\n// [Symbol.iterator]: () => retVal,\n// [Symbol.asyncIterator]: () => retVal,\n// // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n// next: () => {\n// if (isAsyncInput || isAsyncNextFn) {\n// return generateNextReturnValAsync();\n// }\n// return generateNextReturnVal();\n// },\n// };\n\n// return retVal as any;\n// };\n\n// return (itIn: Iterator | AsyncIterator) => operatorFunction(itIn, initialStateFactory());\n// }\n// };\n\n/**\n * UNFINISHED (some tests are failing when using this version) !!!\n *\n * EXPERIMENTAL VERSION OF THIS FUNCTION that tries to rewrite the functions\n * after we've established which parts are synchronous (input iterator next, nextFn result, ...)\n * in order to avoid checking this over and over again.\n *\n * An operator is 'a function that generates a transIterator'.\n * So for example filter(...) is an operator, because when called with an argument\n * (the filter function) the result of that will be another function which is the transIterator.\n *\n * A transIterator is simply a function with an iterator as single argument which will return\n * another iterator. This way we can easily 'build a chain of mulitple transIterators'.\n * So it transforms iterators, which is why I have called it transIterator (~transducers).\n *\n * powerMap is a function that generates transIterators that\n * will work both on synchronous and asynchronous iterators.\n * The factory needs to be provided with a single function of the form:\n *\n * ```typescript\n * (nextOfPreviousIteratorInTheChain, state, operatorParams) => TNextFnResult | Promise<[TNextFnResult]>\n * ```\n * and an initial state\n *\n * * nextOfPreviousIteratorInTheChain is the (resolved if async) result of a next call of the input\n * iterator. This means it will be of the form { done: true } or { done: false, value: <...> }.\n * * The state parameter is used to allow operators to have state, but not all operators need this.\n * For example: a 'map' operator doesn't need state, but the 'skip' operator would need to keep\n * track of how many records have passed.\n * * The operator params are the argument that is given to the operator function, like a number for\n * a 'take' operator, or the filter function for a 'filter' operator.\n *\n * Check the readme for some examples on how to write your own operators with powerMap\n * (or check the source code as all the available operators have been built using this function).\n *\n * BEWARE: NEVER MODIFY THE STATE OBJECT (or any of its children!), ALWAYS RETURN A NEW VALUE!\n *\n * QUESTION: would it be better to have an initial state producing function instead of an initial\n * state?\n * This way, even if nextFn would modify the state, it wouldn't mess with other instances\n * of the same operator? Because if we'd like to deep clone the initial state ourselves, we might\n * end up with some complex cases when classes are involved (I hope no one who's interested in\n * this library will want to use classes in their state, because the library is more 'functional\n * programming' oriented)\n *\n * @param nextFn\n * @param initialStateFactory a function that generates the initialSate\n * @returns a funtion taking an iterator (and optionally some argument) as input and that has an iterator as output\n *\n * @category util\n */\nconst itr8OperatorFactoryExperimental = function <\n TIn = unknown,\n TOut = unknown,\n TState = unknown,\n TParam1 = void,\n TParam2 = void,\n TParam3 = void,\n TParam4 = void,\n>(\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n ) => TNextFnResult | Promise>,\n initialStateFactory: (\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n ) => TState,\n): (\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n) => TTransIteratorSyncOrAsync {\n return function (\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n ): TTransIteratorSyncOrAsync {\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n done: boolean;\n };\n\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n done: false,\n };\n\n let nextInPromiseOrValue:\n | IteratorResult\n | Promise>\n | undefined = undefined;\n // let nextIn: IteratorResult | undefined = undefined;\n let isAsyncInput: boolean | undefined = undefined;\n function updateNextInPromiseOrValue() {\n nextInPromiseOrValue = itIn.next();\n if (isAsyncInput === undefined)\n isAsyncInput = isPromise(nextInPromiseOrValue);\n }\n let isAsyncNextFn: boolean | undefined = undefined;\n // let state = pState !== undefined ? pState : initialState;\n // let state = pState;\n\n // let currentOutputIterator: Iterator | AsyncIterator | undefined = undefined;\n // let isAsyncCurrentOutputIterator:boolean | undefined = undefined;\n // let done = false;\n\n /**\n * Can/should we make this kind of recursive?\n * Figure out based on the input params whether we need to:\n * * return done because done = true\n * * return the next value of the current iterator\n * or empty the current iterator if we're at the end and call generateNextReturnVal\n * * do a call to nextFn\n * * if next = async, call generateNextReturnValAsync to handle this case\n * * set done to true if that is what it returns and call generateNextReturnVal\n * * return the value if it returns a value\n * * set current iterator if it returns an iterable and call generateNextReturnVal\n * @returns\n */\n let generateNextReturnVal =\n (): // itIn:Iterator | AsyncIterator,\n // nextFn: (nextIn: IteratorResult, state: TState, param1: TParam1, param2: TParam2, param3: TParam3, param4: TParam4, ...otherParams:unknown[]) =>\n // TNextFnResult | Promise>,\n // operatorState:TOperatorState\n IteratorResult | Promise> => {\n const nextReturnVal = thenable(itIn.next()).then(\n (nextIn, isSyncInput) => {\n return thenable(\n nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n ),\n ).then((nextFnResult, isSyncNextFn) => {\n // nextFnResult as TNextFnResult\n if (\"state\" in nextFnResult)\n operatorState.state = nextFnResult.state as TState;\n\n let retVal;\n if (nextFnResult.done) {\n operatorState.done = true;\n // return generateNextReturnVal();\n retVal = { done: true };\n } else if (\"value\" in nextFnResult) {\n retVal = { done: false, value: nextFnResult.value };\n } else if (\"iterable\" in nextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n nextFnResult.iterable,\n );\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n // return generateNextReturnVal();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n // return generateNextReturnVal();\n }\n\n // now we can rewrite the current function in an optimized way because we know\n // which parts are async (if any) and which not\n // const newGenerateNextReturnVal = new (isSyncInput && isSyncNextFn ? Function : AsyncFunction)(\n // 'itIn',\n // 'nextFn',\n // 'operatorState',\n // `\n // // while loop instead of calling this function recursively (call stack can become too large)\n // // console.log('operatorState', operatorState);\n // while (true) {\n // if (operatorState.done) {\n // return { value: undefined, done: true };\n // }\n // // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n // if (operatorState.currentOutputIterator) {\n // const possibleNextValueOrPromise = operatorState.currentOutputIterator.next();\n // // if (isPromise(possibleNextValueOrPromise)) {\n // // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // // return { done: true };\n // // }\n // const possibleNext = possibleNextValueOrPromise;\n\n // if (possibleNext.done) {\n // operatorState.currentOutputIterator = undefined;\n // } else {\n // return possibleNext;\n // }\n // }\n\n // // no running iterator, so we need to call nextFn again\n // const nextIn = ${isSyncInput ? '' : 'await '}itIn.next();\n // const [_itIn, _nextFn, _operatorState, ...otherArgs] = [...arguments];\n // const curNextFnResult = ${isSyncNextFn ? '' : 'await '}nextFn(nextIn, operatorState.state, ...otherArgs);\n // if ('state' in curNextFnResult) operatorState.state = curNextFnResult.state as TState;\n\n // if (curNextFnResult.done) {\n // operatorState.done = true;\n // } else if ('value' in curNextFnResult) {\n // return { done: false, value: curNextFnResult.value };\n // } else if ('iterable' in curNextFnResult) {\n // if (operatorState.currentOutputIterator !== undefined) throw new Error('currentOutputIterator should be undefined at this point');\n // // operatorState.currentOutputIterator = (curNextFnResult.iterable[Symbol.iterator] || curNextFnResult.iterable[Symbol.asyncIterator])(); // itr8FromIterable(curNextFnResult.iterable);\n // if (curNextFnResult.iterable[Symbol.iterator]) {\n // operatorState.currentOutputIterator = curNextFnResult.iterable[Symbol.iterator]();\n // } else if (curNextFnResult.iterable[Symbol.asyncIterator]) {\n // operatorState.currentOutputIterator = curNextFnResult.iterable[Symbol.asyncIterator]();\n // }\n\n // if (!operatorState.currentOutputIterator || operatorState.currentOutputIterator.next === undefined) {\n // throw new Error('Error while trying to get output iterator, did you specify something that is not an Iterable to the \\\\'iterable\\\\' property? (when using a generator function, don\\\\'t forget to call it in order to return an IterableIterator!)');\n // }\n // // goto next round of while loop\n // } else {\n // // we need to call nextIn again\n // // goto next round of while loop\n // }\n // }\n // `,\n // ) as () => IteratorResult | Promise>;\n\n /**\n * Can return a value or undefined\n * @param curNextFn\n */\n const handleCurNextFnResult = (\n curNextFnResult: TNextFnResult,\n ): IteratorResult | undefined => {\n if (curNextFnResult.done) {\n operatorState.done = true;\n } else if (\"value\" in curNextFnResult) {\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n // operatorState.currentOutputIterator = (curNextFnResult.iterable[Symbol.iterator] || curNextFnResult.iterable[Symbol.asyncIterator])(); // itr8FromIterable(curNextFnResult.iterable);\n if (curNextFnResult.iterable[Symbol.iterator]) {\n operatorState.currentOutputIterator =\n curNextFnResult.iterable[Symbol.iterator]();\n } else if (curNextFnResult.iterable[Symbol.asyncIterator]) {\n operatorState.currentOutputIterator =\n curNextFnResult.iterable[Symbol.asyncIterator]();\n } else {\n // (!operatorState.currentOutputIterator || operatorState.currentOutputIterator.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n return undefined;\n };\n\n let newGenerateNextReturnVal;\n if (isSyncInput && isSyncNextFn) {\n // sync version\n newGenerateNextReturnVal = () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // console.log('operatorState', operatorState);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = itIn.next() as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n } else if (isSyncInput) {\n newGenerateNextReturnVal = async () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // console.log('operatorState', operatorState);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = itIn.next() as IteratorResult;\n const curNextFnResult = (await nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n )) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n } else if (isSyncNextFn) {\n newGenerateNextReturnVal = async () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // console.log('operatorState', operatorState);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = (await itIn.next()) as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n } else {\n newGenerateNextReturnVal = async () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = (await itIn.next()) as IteratorResult;\n const curNextFnResult = (await nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n )) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n }\n\n // now overwrite the function within the same context as the original function\n generateNextReturnVal = newGenerateNextReturnVal;\n\n // console.log(' ----> next return val will be', retVal);\n return retVal || generateNextReturnVal(); // generateNextReturnVal(itIn, nextFn, operatorState, param1, param2, param3, param4, ...otherParams);\n });\n },\n ).src;\n\n // console.log(' ----> next return val will be', nextReturnVal);\n return nextReturnVal;\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const retVal = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: ():\n | IteratorResult\n | Promise>\n | IteratorResult\n | Promise> => {\n return generateNextReturnVal(); // generateNextReturnVal(itIn, nextFn, operatorState, param1, param2, param3, param4, ...otherParams);\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n\n return (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator =>\n operatorFunction(\n itIn,\n initialStateFactory(param1, param2, param3, param4, ...otherParams),\n );\n };\n};\n\nexport { powerMapWithoutDoAfter as powerMap };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Only take elements as long as the filter function returns true.\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/general\n */\nconst takeWhile = (filterFn: (x: TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) return { done: true };\n\n return thenable(filterFn(nextIn.value)).then((filterFnResult) => {\n if (filterFnResult) return { done: false, value: nextIn.value };\n return { done: true };\n }).src;\n },\n () => undefined,\n );\n\nexport { takeWhile };\n", "import { takeWhile } from \"../operators/general/takeWhile.js\";\nimport { pipe } from \"../util/index.js\";\nimport { forEach } from \"./forEach.js\";\n\n/**\n * When you want to process the same iterator mutltiple times in different ways\n * (you can think of it as 'splitting the stream'),\n * it would be cool to have a way to 'subscribe' many times to the same iterator.\n * An IterableIterator returns an iterator, but that will always return the current iterator,\n * and not a new one.\n *\n * This function produces an Iterable that returns a new iterator each time [Symbol.asyncIterator]()\n * gets called, so one needs to call next on all output iterators separately to get the next element\n * of the input iterator.\n *\n * This method creates a function that turns the iterator into an Iterable that returns\n * a new iterator on calling [Symbol.asynIterator] that starts from the current element\n * (or the oldest element any of the subscribers is at?) that we are at in the source iterator.\n *\n * In order to support the fact that not all output iterators will be pulled at the same time,\n * we need to keep a cache + the position that each iterator is at.\n *\n * @todo In order to protect ourselves from 'abandoned' iterators, a timeout could be used\n * to clean them up, so the cache can be emptied up to the oldest 'active' iterator.\n *\n * @category interface/standard\n */\nfunction itr8ToMultiIterable(\n it:\n | Iterator\n | AsyncIterator /*, abandonedTimeoutMilliseconds = Infinity */,\n): AsyncIterable | Iterable {\n const subscriberMap: Map<\n AsyncIterableIterator | IterableIterator,\n number\n > = new Map();\n const buffer: Map | Promise>> =\n new Map();\n\n /** Helper to remove old elements from buffer that all current subscribers have read */\n const cleanBuffer = () => {\n const minIndex = Math.min(...subscriberMap.values());\n // Maps are iterated in insertion order !\n // ['IMPERATIVE' VERSION]\n // for (const i of buffer.keys()) {\n // if (i < minIndex) {\n // buffer.delete(i);\n // } else {\n // break;\n // }\n // }\n // ['DECLARATIVE' VERSION]\n pipe(\n buffer.keys(),\n takeWhile((i) => i < minIndex),\n forEach((i) => {\n buffer.delete(i);\n }),\n );\n };\n const iteratorGetter = () => {\n const outIt: IterableIterator | AsyncIterableIterator = {\n [Symbol.iterator]: () => outIt as IterableIterator,\n [Symbol.asyncIterator]: () => outIt as AsyncIterableIterator,\n next: () => {\n const index = subscriberMap.get(outIt) as number;\n if (!buffer.has(index)) {\n buffer.set(index, it.next());\n }\n // remove old stuff in buffer\n cleanBuffer();\n\n subscriberMap.set(outIt, index + 1);\n // if (isPromise(buffer.get(index))) {\n // return (buffer.get(index) ?? { done: true }) as Promise>;\n // } else {\n return (buffer.get(index) ?? { done: true }) as IteratorResult;\n // }\n },\n return: (value?: T) => {\n subscriberMap.delete(outIt);\n cleanBuffer();\n return { done: true, value };\n },\n throw: (error?) => {\n subscriberMap.delete(outIt);\n cleanBuffer();\n return { done: true, value: undefined };\n },\n };\n\n // add the new iterator to the subscriberMap\n subscriberMap.set(\n outIt,\n buffer.size === 0 ? 0 : Math.min(...buffer.keys()),\n );\n // TODO: set a disconnect timeout (we'll need to store the last get time, or the timeout id)\n return outIt;\n };\n\n const retVal: AsyncIterable | Iterable = {\n [Symbol.asyncIterator]: () => iteratorGetter() as AsyncIterableIterator,\n [Symbol.iterator]: () => iteratorGetter() as IterableIterator,\n };\n\n // subscriberMap.set(outIt, buffer.size > 0 ? buffer.values.next().value : 0);\n return retVal;\n}\n\nexport { itr8ToMultiIterable };\n", "import { isPromise } from \"../../util/index.js\";\n\n/**\n * Probably only useful on async iterators.\n *\n * It will turn an async iterator into an asynchronous iterator that will always return the\n * last known value, while waiting for the promise on the incoming iterator to resolve.\n *\n * Every value on the incoming iterator will be returned at least once in order to keep\n * the operator 'passive'. This operator will not actively drain the incoming iterator.\n *\n * @example\n * ```typescript\n * // input iterator\n * const it = itr8.itr8Pushable();\n * // output iterator that will always return the mostRecent value of the input iterator\n * const itOut = pipe(it, mostRecent('My initial value'));\n *\n * await sleep(1);\n * await itOut.next(); // => { value: 'My initial value' }\n * await itOut.next(); // => { value: 'My initial value' }\n * await sleep(1);\n * await itOut.next(); // => { value: 'My initial value' }\n *\n * it.push('2nd value');\n * await sleep(1);\n * await itOut.next(); // => { value: '2nd value' }\n * await itOut.next(); // => { value: '2nd value' }\n *\n * it.push('third value');\n * // sync so 'third value' promise not resolved yet at this point\n * await itOut.next(); // => { value: '2nd value' }\n * await sleep(1);\n * await itOut.next(); // => { value: 'third value' }\n * await itOut.next(); // => { value: 'third value' }\n * await sleep(1);\n * await itOut.next(); // => { value: 'third value' }\n *\n * // see evey value at least once!!!\n * it.push('fourth value');\n * it.push('fifth value');\n * // sync so 'third value' promise not resolved yet\n * await itOut.next(); // => { value: 'third value' }\n * await sleep(0);\n * await itOut.next(); // => { value: 'fourth value' }\n * await sleep(0);\n * await itOut.next(); // => { value: 'fifth value' }\n *\n * it.done();\n * // sync so 'done' promise not resolved yet\n * await itOut.next(); // => { value: 'fifth value' }\n * await sleep(1);\n * await itOut.next(); // => { done: true }\n * await itOut.next(); // => { done: true }\n * ```\n *\n * @category operators/async\n */\nconst mostRecent = (initalValue: T) => {\n return (it: Iterator | AsyncIterator): AsyncIterator => {\n let nextOut: IteratorResult = { value: initalValue };\n let resolveNextOutRead;\n\n const handleInputPromise = async () => {\n let nextOutRead: Promise | undefined = undefined;\n do {\n if (isPromise(nextOutRead)) {\n await nextOutRead;\n }\n nextOut = await it.next();\n nextOutRead = new Promise((resolve, reject) => {\n resolveNextOutRead = resolve;\n });\n } while (!nextOut.done);\n };\n\n const retVal: AsyncIterableIterator = {\n // [Symbol.iterator]: () => retVal as IterableIterator,\n [Symbol.asyncIterator]: () => retVal,\n next: async () => {\n if (resolveNextOutRead === undefined) {\n handleInputPromise();\n } else {\n resolveNextOutRead(true);\n }\n return nextOut;\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: async (value?: any) => {\n it.return?.();\n return { done: true, value };\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: async (err: any) => {\n it.throw?.(err);\n return { done: true, value: undefined };\n },\n };\n\n return retVal;\n };\n};\n\nexport { mostRecent };\n", "import { isPromise } from \"../../util/index.js\";\n\n/**\n * Probably only useful on async iterators.\n *\n * Instead of only asking for the next value of the incoming iterator when a next call comes in,\n * make sure to do one or more next calls to the incoming iterator up-front, to decrease the\n * waiting time.\n *\n * This can be used to kind of 'parallelize' the processing, while respecting the order.\n * If the order is not important, you might want to take a look a the parallel(...) operator!\n *\n * This one can be useful, when the result needs to do some I/O (for example an API get\n * or a DB fetch), and processing also takes up a certain amount of time due to I/O.\n * In this case, it makes sense to already do the next call on the incoming iterator up-front,\n * so that it will hopefully already have resolved by the time you need it for processing.\n *\n * Nothing will be done before the first next call, but after the first next call the iterator\n * will always try to have a buffer with the given amount of prefetched results (which will be\n * impossible to achieve if processing is generally faster than fetching).\n *\n * forEach actually by default acts like it has a prefetch of 1, but imagine a case where the\n * processing time can vary significantly. Then, when processing takes a long time, by prefetching\n * more than one you can make sure that there is no waiting time for the next (maybe very fast)\n * processing to start because the promises they act upon are already resolved by the time they\n * are needed.\n *\n * @category operators/async\n */\nconst prefetch = (amount: number) => {\n return (\n it: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n let inputs: Array> | IteratorResult> = [];\n let isAsyncInput: boolean;\n const addInputIfNeeded = async () => {\n if (inputs.length < amount) {\n if (isAsyncInput && inputs.length > 0) await inputs[0];\n const next = it.next();\n if (isPromise(next)) {\n // console.log(' add another (async) input, current nr of inputs = ', inputs.length, ' < ', amount);\n isAsyncInput = true;\n next.then((n) => {\n if (!n.done) {\n // console.log(' then: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n addInputIfNeeded();\n }\n });\n }\n inputs.push(next);\n }\n };\n\n const retVal = {\n [Symbol.asyncIterator]: () => retVal as AsyncIterableIterator,\n [Symbol.iterator]: () => retVal as IterableIterator,\n next: () => {\n // console.log(' next: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n addInputIfNeeded();\n if (inputs.length > 0) {\n const [firstInput, ...remainingInputs] = inputs;\n inputs = remainingInputs;\n // console.log(' next: call 2 to addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n addInputIfNeeded();\n // console.log(' next: return ', firstInput);\n return firstInput;\n }\n return isAsyncInput\n ? (Promise.resolve({ done: true, value: undefined }) as Promise<\n IteratorResult\n >)\n : ({ done: true, value: undefined } as IteratorResult);\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n it.return?.();\n return isAsyncInput\n ? Promise.resolve({ done: true, value })\n : { done: true, value };\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n it.throw?.(err);\n return isAsyncInput\n ? Promise.resolve({ done: true, value: undefined })\n : { done: true, value: undefined };\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n};\n\nexport { prefetch };\n", "import { pipe } from \"../../util/index.js\";\nimport {\n forEach,\n itr8FromSingleValue,\n itr8Pushable,\n itr8ToArray,\n} from \"../../interface/index.js\";\nimport { TPushable, TTransIteratorSyncOrAsync } from \"../../types\";\n\n/**\n * This operator should make it easy to run asynchronous transIterators in parallel, in order\n * to speed things up.\n * You can think of it as multiple lanes on a highway, but the output order of the elements\n * is still guaranteed by default! But if the order doesn't matter, you can speed up things\n * even more by allowing elements whose processing goes faster to overtake the slower ones.\n *\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502input iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \u2502\n * \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510\n * \u2502transform\u2502 \u2502transform\u2502\n * \u2502 lane 1 \u2502 \u2502 lane 2 \u2502 ...\n * \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518\n * \u2502 \u2502\n * \u2502 \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502output iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * The first argument specifies the maximum concurrency and whether the order must be respected.\n * All arguments after that are the transIterators that make up the algorithm to be run in parallel.\n *\n * 'keepOrder: false' can be useful in cases where the elements can be processed independently.\n * For example:\n * if you would model a webserver as a transIterator that turns a stream of http requests\n * into a stream of http responses, their processing can be done independently, and it would\n * make sense to respond as quickly as possible, instead of waiting for the previous request to be\n * processed first.\n *\n * This should be an ideal combination with the runInWorker operator so we can easily distribute\n * the work over the wanted amount of worker threads.\n *\n * @example\n * ```typescript\n * // run google searches and transform the result with an online api to produce a map of results\n * // but run maximum 4 api requests in parallel to speed things up\n * await pipe(\n * itr8FromArray([ 'Garfield', 'H\u00E4gar the Horrible', 'Droopy', 'Calvin and Hobbes', 'Fritz the Cat', 'Popeye' ])\n * parallel(\n * { concurrency: 4 },\n * map(async (term) => ...), // a call to google search to get the search results in html\n * map(async (html) => ...), // another api call that turns the html into structered json { name: 'Garfield', searchResults: [ ... ] }\n * ),\n * map(({name, searchResults}) => [name, searchResults]),\n * itr8ToObject, // like Object.fromEntries but for both synchronous and asynchronous iterators\n * )\n * // => {\n * // 'Garfield': [ ...urls ],\n * // 'H\u00E4gar the Horrible': [ ...urls ],\n * // 'Droopy': [ ...urls ],\n * // 'Calvin and Hobbes': [ ...urls ],\n * // 'Fritz the Cat': [ ...urls ],\n * // 'Popeye': [ ...urls ],\n * // }\n * ```\n *\n * @param options\n * @param transIt\n * @param {...(it:Iterator | AsyncIterator)=>Iterator | AsyncIterator} moreTransIts\n * @returns\n *\n * @category operators/async\n */\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E): E;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F): F;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G): G;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H): H;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H, fn9: (x: H) => I): I;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H, fn9: (x: H) => I, fn10: (x: I) => J): J;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H, fn9: (x: H) => I, fn10: (x: I) => J, ...moreFns: Array<(x: unknown) => unknown>): unknown;\n// function parallel(\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt: TTransIteratorSyncOrAsync,\n ...moreTransIts: Array\n): TTransIteratorSyncOrAsync {\n // combine all parameters into a single transIterator in order to apply it\n const transItsCombined = moreTransIts.reduce(\n (acc, cur) => (input) => cur(acc(input)),\n transIt,\n );\n // = compose(transIt, ...moreTransIts)\n\n if (options.keepOrder === undefined || options.keepOrder) {\n return (\n inIt: Iterator | AsyncIterator,\n ): AsyncIterableIterator => {\n type TItOfItsElement = {\n callbackIt: TPushable & AsyncIterableIterator;\n subIt: TPushable & AsyncIterableIterator;\n };\n\n async function* iteratorOfIterables() {\n // create an iterator to push the results of each 'lane' to\n const outIteratorOfIterators = itr8Pushable();\n\n // first setup the (concurrent) forEach on the incoming iterator, so that things will be pushed to the pushable iterator\n (async () => {\n // const start = Date.now();\n // const timePassed = () => Date.now() - start;\n await pipe(\n inIt,\n forEach(\n async (inElement) => {\n // console.log(`${JSON.stringify(inElement)}: taking lane (${timePassed()} ms)`);\n const itOfItsElement: TItOfItsElement = {\n callbackIt: itr8Pushable(),\n subIt: itr8Pushable(),\n };\n outIteratorOfIterators.push(itOfItsElement);\n // actively drain the subIterator to force parallel processing\n // and push the results onto the subItPushable\n const subIt = transItsCombined(itr8FromSingleValue(inElement));\n // await forEach(itOfItsElement.subIt.push)(subIt);\n await forEach((v) => {\n // console.log(`${JSON.stringify(inElement)}: Pushing ${JSON.stringify(v)} to outIterator (${timePassed()} ms)`);\n itOfItsElement.subIt.push(v);\n })(subIt);\n // console.log(`${JSON.stringify(inElement)}: Pushing DONE to outIterator (${timePassed()} ms)`);\n itOfItsElement.subIt.done();\n // now wait until we get a signal that this subIterator has been processed (pulled in)\n // so this 'lane' can start processing a new record\n await itr8ToArray(itOfItsElement.callbackIt);\n // console.log(`${JSON.stringify(inElement)}: clearing lane because outIterator has processed all elemants... (${timePassed()} ms)`);\n },\n { concurrency: options.concurrency },\n ),\n );\n\n // after the forEach, make sure we indicate that the iterator is done!\n outIteratorOfIterators.done();\n })();\n\n // second we'll loop through the outIteratorOfIterators\n for await (const subItElement of outIteratorOfIterators) {\n yield* subItElement.subIt;\n // send signal back to forEach that the processing has finished for this subIterator\n subItElement.callbackIt.done();\n }\n }\n return iteratorOfIterables() as AsyncIterableIterator;\n };\n } else {\n return (\n inIt: Iterator | AsyncIterator,\n ): AsyncIterableIterator => {\n type TItElement =\n | { callbackIt: TPushable & AsyncIterableIterator }\n | { value: T };\n\n async function* iteratorOfValues() {\n // create an iterator to push calculated values onto\n const outIterator = itr8Pushable();\n\n // first setup the (concurrent) forEach on the incoming iterator, so that things will be pushed to the pushable iterator\n (async () => {\n await pipe(\n inIt,\n forEach(\n async (inElement) => {\n // actively drain the subIterator to force parallel processing\n // and push the results onto the pushable outIterator\n const subIt = transItsCombined(itr8FromSingleValue(inElement));\n await forEach((v) => outIterator.push({ value: v }))(subIt);\n // await forEach((v) => {\n // console.log(`${JSON.stringify(inElement)}: Pushing ${JSON.stringify(v)} to outIterator`);\n // outIterator.push({ value: v });\n // })(subIt);\n const callbackIt = itr8Pushable();\n // console.log(`${JSON.stringify(inElement)}: Pushing DONE to outIterator`);\n outIterator.push({ callbackIt });\n // now wait until we get a signal that this subIterator has been processed (pulled in)\n // so this 'lane' can start processing a new record\n await itr8ToArray(callbackIt);\n // console.log(`${JSON.stringify(inElement)}: clearing lane because outIterator has processed all elemants...`);\n },\n { concurrency: options.concurrency },\n ),\n );\n\n // after the forEach, make sure we indicate that the iterator is done!\n outIterator.done();\n })();\n\n // second we'll loop through the outIterator\n for await (const subItElement of outIterator) {\n if ((subItElement as any).callbackIt === undefined) {\n yield (subItElement as { value: T }).value;\n } else {\n // send signal back to forEach that the processing has finished for this subIterator\n (\n subItElement as {\n callbackIt: TPushable & AsyncIterableIterator;\n }\n ).callbackIt.done();\n }\n }\n }\n return iteratorOfValues() as AsyncIterableIterator;\n };\n }\n}\n\nexport { parallel };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Return true if every item returns true on the test function.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4, 5, 6 ]),\n * every((x) => x > 2), // => [ false ]\n * );\n * ```\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/boolean\n */\nconst every = (filterFn: (TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return { done: false, value: true, state: { done: true } };\n\n return thenable(filterFn(nextIn.value)).then((result) => {\n if (result) return { done: false, state: { done: false } };\n return { done: false, value: result, state: { done: true } };\n }).src;\n },\n () => ({ done: false }),\n );\n\nexport { every };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Return true if at least 1 item returns true on the test function.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4, 5, 6 ]),\n * some((x) => x > 2), // => [ true ]\n * );\n * ```\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/boolean\n */\nconst some = (filterFn: (TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return { done: false, value: false, state: { done: true } };\n\n return thenable(filterFn(nextIn.value)).then((result) => {\n if (result)\n return { done: false, value: result, state: { done: true } };\n return { done: false, state: { done: false } };\n }).src;\n },\n () => ({ done: false }),\n );\n\nexport { some };\n", "import { isPromise } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\nimport { TNextFnResult } from \"../../types.js\";\n\n/**\n * Translate each element into something else by applying the supplied mapping function\n * to each element.\n *\n * The mapping function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @param fn\n *\n * @category operators/general\n */\nconst map = (mapFn: (v: TIn) => TOut | Promise) => {\n const returnIteratorResultSync = (\n value: TOut,\n ): TNextFnResult => ({\n done: false,\n value,\n });\n const returnIteratorResultAsync = async (\n valuePromise: Promise,\n ): Promise> => ({\n done: false,\n value: await valuePromise,\n });\n let returnIteratorResult = (\n mapFnResult: TOut | Promise,\n ): TNextFnResult | Promise> => {\n if (isPromise(mapFnResult)) {\n returnIteratorResult = returnIteratorResultAsync;\n } else {\n returnIteratorResult = returnIteratorResultSync;\n }\n return returnIteratorResult(mapFnResult);\n };\n return powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n } else {\n return returnIteratorResult(mapFn(nextIn.value));\n // return thenable(mapFn(nextIn.value)).then((value) => ({\n // done: false,\n // value,\n // })).src; // return the 'raw' value or promise, not the 'wrapped' version\n\n // const nextValOrPromise = mapFn(nextIn.value);\n // if (isPromise(nextValOrPromise)) {\n // return (async () => {\n // return {\n // done: false,\n // value: await nextValOrPromise,\n // }\n // })();\n // } else {\n // return {\n // done: false,\n // value: nextValOrPromise,\n // }\n // }\n }\n },\n () => undefined,\n );\n};\n\nexport { map };\n", "import { pipe } from \"../../util/index.js\";\nimport {\n itr8FromIterable,\n itr8ToMultiIterable,\n} from \"../../interface/index.js\";\nimport { TTransIteratorSyncOrAsync } from \"../../types.js\";\nimport { map } from \"./map.js\";\nimport { isPromise } from \"../../util/index.js\";\n\n/**\n * This operator should make it easy to perform multiple calculations on the same input\n * operator, and returning a tuple containing the multiple outputs.\n * This can be useful for example if you need to add a timestamp, get the running average,\n * the running max, and the running total of the same data, and you only want to iterate\n * over the data once.\n *\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502input iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \u2502 \u2502 \u2502\n * \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510\n * \u2502 transIt \u2502 \u2502 transIt \u2502 \u2502 transIt \u2502\n * \u2502 1 \u2502 \u2502 2 \u2502 ... \u2502 n \u2502\n * \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518\n * \u2502 \u2502 | \u2502\n * \u2502 \u2502 | \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \n * \u2502\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502output iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * All arguments are the transIterators that need to be run (use compose(for more complex operations)).\n *\n * @example\n * ```typescript\n * await pipe(\n * itr8FromArray([ 1, 2, 3, 4 ])\n * branchAndMerge(\n * identity(), // keep the original values as the first element of the tuple\n * runningAverage(),\n * runningTotal(),\n * ),\n * map(([value, avg, total]) => ({ value, avg, total })),\n * itr8ToArray,\n * )\n * // => [\n * // { value: 1, avg: 1, total: 1 },\n * // { value: 2, avg: 1.5, total: 3 },\n * // { value: 3, avg: 2, total: 6 },\n * // { value: 4, avg: 2.5, total: 10 },\n * // ]\n * ```\n *\n * @param options\n * @param transIt\n * @param {...(it:Iterator | AsyncIterator)=>Iterator | AsyncIterator} moreTransIts\n * @returns\n *\n * @category operators/async\n */\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n transIt6: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n transIt6: TTransIteratorSyncOrAsync,\n transIt7: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n transIt6: TTransIteratorSyncOrAsync,\n transIt7: TTransIteratorSyncOrAsync,\n transIt8: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt: TTransIteratorSyncOrAsync,\n ...moreTransIts: Array\n): TTransIteratorSyncOrAsync {\n return function (it) {\n const multiIterable = itr8ToMultiIterable(it);\n const itInput = itr8FromIterable(multiIterable);\n // const transIts = [transIt, ...moreTransIts];\n const moreTransItIterators = moreTransIts.map((transIt) =>\n pipe(itr8FromIterable(multiIterable), transIt),\n );\n\n let isAsync: boolean;\n const itOut = pipe(\n itInput,\n map((value) => {\n const itrResultsPossiblePromises = moreTransItIterators.map(\n (transItIterator) => transItIterator.next(),\n );\n if (isAsync === undefined) {\n isAsync = itrResultsPossiblePromises.some((result) =>\n isPromise(result),\n );\n }\n\n if (isAsync === false) {\n return [\n value,\n ...(\n itrResultsPossiblePromises as Array>\n ).map((result) => result.value),\n ];\n } else if (isAsync === true) {\n let otherValues: Array = [];\n return (async () => {\n for await (const result of itrResultsPossiblePromises) {\n otherValues.push(result.value);\n }\n return [value, ...otherValues];\n })();\n }\n }),\n );\n return itOut;\n };\n}\n\nexport { branchAndMerge };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Removes consecutive doubles.\n * If no argument is provided, standard !== will be used to compare both values.\n * If a mapping fn is provided, the result of the mapping fn will be compared using !==,\n * which means the mapping function should produce a 'simple' types like number or string.\n *\n * (The alternative option would have been to pass 2 arguments to the compare fn and if\n * it returns true, the elements would be considered equal)\n *\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ 1, 2, 2, 2, 3, 4, 4, 3 ]),\n * itr8.dedup(), // => [ 1, 2, 3, 4, 3 ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ { id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 4 }, { id: 3 } ])\n * itr8.dedup((a:{ id:number }) => id ) // => [ [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 3 } ];\n * );\n * ```\n *\n * @param mapFn\n *\n * @category operators/general\n */\nconst dedup = (mapFn?: (v: TIn) => any) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n\n // promise if mapFn is async!\n const valueToCompare = mapFn ? mapFn(nextIn.value) : nextIn.value;\n return thenable(valueToCompare).then((v) => {\n return v !== state\n ? { done: false, value: nextIn.value, state: v }\n : { done: false, state: v };\n }).src;\n },\n () => undefined,\n );\n\nexport { dedup };\n", "import { TNextFnResult } from \"../../types.js\";\nimport { isPromise, thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Only keep elements where the filter function returns true.\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/general\n */\nconst filter = (filterFn: (v: TIn) => boolean | Promise) => {\n // EXPERIMENTAL: create a self-replacing function (depending on sync or async)\n let generateNextFnResultFromFilterFnResult = function (\n firstFilterFnResult: boolean | Promise,\n nextIn,\n ): TNextFnResult | Promise> {\n const f = (filterFnResult, nextIn: IteratorResult) => {\n if (filterFnResult) {\n return { done: false, value: nextIn.value } as const;\n } else {\n return { done: false } as const;\n }\n };\n\n generateNextFnResultFromFilterFnResult = isPromise(firstFilterFnResult)\n ? (resultPromise, nextIn) =>\n (resultPromise as Promise).then((result) =>\n f(result, nextIn),\n )\n : f;\n return generateNextFnResultFromFilterFnResult(firstFilterFnResult, nextIn);\n };\n\n return powerMap(\n (nextIn, _state) => {\n if (nextIn.done) return { done: true };\n\n return generateNextFnResultFromFilterFnResult(\n filterFn(nextIn.value),\n nextIn,\n );\n\n // OLD: thenable is simple to use, but not performant\n // return thenable(filterFn(nextIn.value)).then((result) => {\n // if (result) return { done: false, value: nextIn.value };\n // return { done: false };\n // }).src;\n\n // const result = filterFn(nextIn.value);\n // if (isPromise(result)) {\n // return (async () => {\n // if (await result) return { done: false, value: nextIn.value };\n // return { done: false };\n // })();\n // } else {\n // if (result) return { done: false, value: nextIn.value };\n // return { done: false };\n // }\n },\n () => undefined,\n );\n};\n\nexport { filter };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * The incoming elements are arrays, and send out each element of the array 1 by one.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ [1, 2], [3, 4], [5, 6] ]),\n * flatten(), // => [ 1, 2, 3, 4, 5, 6 ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst flatten = () =>\n powerMap, TIn, void>(\n (nextIn, _state) => {\n if (nextIn.done) return { done: true };\n return { done: false, iterable: nextIn.value };\n },\n () => undefined,\n );\nexport { flatten };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Group the incoming elements so the output iterator will return arrays/tuples of a certain size.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4, 5, 6 ]),\n * groupPer(2), // => [ [1, 2], [3, 4], [5, 6] ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst groupPer = (groupSize: number) =>\n powerMap, { done: boolean; buffer: Array }>(\n (nextIn, state) => {\n if (state.done || (nextIn.done && state.buffer.length === 0)) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.buffer,\n state: { done: true, buffer: [] },\n };\n } else if (state.buffer.length + 1 === groupSize) {\n return {\n done: false,\n value: [...state.buffer, nextIn.value],\n state: { done: false, buffer: [] },\n };\n }\n return {\n done: false,\n state: { ...state, buffer: [...state.buffer, nextIn.value] },\n };\n },\n () => ({ done: false, buffer: [] }),\n );\n\nexport { groupPer };\n", "import { pipe } from \"../../util/index.js\";\nimport { TTransIteratorSyncOrAsync } from \"../../types.js\";\nimport { map } from \"./map.js\";\nimport { isPromise } from \"../../util/index.js\";\n\n/**\n * This operator returns the same iterator, but makes sure it\n * will be an (Async)IterableIterator.\n *\n * @example\n * ```typescript\n * const iterableIterator = await pipe(\n * someBareIterator,\n * identity(),\n * )\n * ```\n *\n * @returns the same (Async)Iterator but guaranteed to be an (Async)IterableIterator\n *\n * @category operators/async\n */\nfunction identity(): TTransIteratorSyncOrAsync {\n return function (\n it: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator {\n if (it[Symbol.asyncIterator]) {\n return it as AsyncIterableIterator;\n } else if (it[Symbol.iterator]) {\n return it as IterableIterator;\n } else {\n const itOut: IterableIterator = {\n next: it.next as () => IteratorResult,\n [Symbol.iterator]: () => itOut,\n };\n return itOut;\n }\n };\n}\n\nexport { identity };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Intersperse the the argument bewteen each element of the iterator.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world', 'and', 'goodbye' ]),\n * intersperse('|'), // => [ [ 'hello', '|', 'world', '|', 'and', '|', 'goodbye' ] ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * intersperse(true), // => [ 1, true, 2, true, 3, true, 4 ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst intersperse = (intersperseThing: unknown) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n } else if (state) {\n return {\n done: false,\n iterable: [intersperseThing, nextIn.value],\n state,\n };\n }\n // first time, just return the first element\n return { done: false, iterable: [nextIn.value], state: true };\n },\n () => false,\n );\n\nexport { intersperse };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * To solve some problems you need to know what the next element(s) is (are) going\n * to be, or look back at the previous value(s).\n *\n * so instead of returning the simple value of the incoming iterator, an object will be returned\n * that looks like this:\n * ```typescript\n * {\n * value: 'the current value',\n * next: [ 'next value', 'next + 1 value' ],\n * previous: [ 'previous value', 'previous - 1 value' ],\n * }\n * ```\n *\n * @example\n * ```typescript\n * // the output of: find src \\( -type d -printf \"%p/\\n\" , ! -type d -print \\)\n * const str = `src/\n * src/interface/\n * src/interface/itr8ToArray.ts\n * src/interface/itr8Pushable.ts\n * src/interface/index.ts\n * src/peer/\n * src/peer/observable.ts\n * src/peer/parseJson.ts\n * src/types.ts\n * src/index.ts\n * src/operators/\n * src/operators/numeric/\n * src/operators/numeric/max.ts\n * src/operators/numeric/min.ts\n * src/operators/numeric/average.ts\n * src/operators/numeric/total.ts\n * src/operators/strings/\n * src/operators/strings/lineByLine.ts\n * src/operators/strings/stringToChar.ts\n * src/operators/general/\n * src/operators/general/uniq.ts\n * src/operators/general/reduce.ts\n * src/operators/general/split.ts\n * src/operators/boolean/\n * src/operators/boolean/every.ts\n * src/operators/boolean/some.ts\n * src/operators/index.ts`;\n *\n * const printableTreeView = pipe(\n * itr8FromString(str),\n * lineByLine(),\n * peek(),\n * // parse the string into a data structure (peeking to next to fill the isLastInLevel & isVeryLast flags)\n * map(({value, next, prev}) => {\n * const valueSplit = value.split('/');\n * const isDir = value.endsWith('/');\n * const pathLength = valueSplit.length - (isDir ? 2 : 1);\n * const nextIsDir = next[0]?.endsWith('/');\n * const nextPathLength = next[0]?.split('/').length - (nextIsDir ? 2 : 1);\n * const isLastInLevel = nextPathLength < pathLength;\n * const isVeryLast = next.length === 0;\n * return { isDir, name: valueSplit[pathLength], level: pathLength, isLastInLevel, isVeryLast };\n * }),\n * // turn the data structure into a new string\n * map(({ isDir, name, level, isLastInLevel, isVeryLast }) => {\n * const padding = pipe(\n * itr8FromSingleValue(' \u2502 ')\n * repeatEach(level - 1),\n * itr8ToString,\n * );\n *\n * const line = !(isLastInLevel || isVeryLast)\n * ? ' \u251C\u2500'\n * : ' \u2514\u2500' // (!isVeryLast ? ' \u2514\u2500' : '\u2500\u2534\u2500')\n * ;\n *\n * const filename = `${isDir ? '\uD83D\uDCC1' : '\uD83D\uDCC4'} ${name}`;\n *\n * return `${padding}${level > 0 ? line : ''}${filename}`;\n * }),\n * intersperse('\\n'),\n * itr8ToString,\n * )\n * // =>\n * // \uD83D\uDCC1 src\n * // \u251C\u2500\uD83D\uDCC1 interface\n * // \u2502 \u251C\u2500\uD83D\uDCC4 itr8ToArray.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC4 itr8Pushable.ts\n * // \u2502 \u2514\u2500\uD83D\uDCC4 index.ts\n * // \u251C\u2500\uD83D\uDCC1 peer\n * // \u2502 \u251C\u2500\uD83D\uDCC4 observable.ts\n * // \u2502 \u2514\u2500\uD83D\uDCC4 parseJson.ts\n * // \u251C\u2500\uD83D\uDCC4 types.ts\n * // \u251C\u2500\uD83D\uDCC4 index.ts\n * // \u251C\u2500\uD83D\uDCC1 operators\n * // \u2502 \u251C\u2500\uD83D\uDCC1 numeric\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 max.ts\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 min.ts\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 average.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 total.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC1 strings\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 lineByLine.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 stringToChar.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC1 general\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 uniq.ts\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 reduce.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 split.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC1 boolean\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 every.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 some.ts\n * // \u2502 \u2514\u2500\uD83D\uDCC4 index.ts\n * ```\n *\n * @category operators/general\n */\nconst peek = (peekForward = 1, peekBackward = 1) =>\n powerMap<\n TIn,\n { value: TIn; previous: TIn[]; next: TIn[] },\n { previous: TIn[]; current: TIn; next: TIn[] }\n >(\n (nextIn, state) => {\n if (nextIn.done) {\n // drain what's left of the next elements\n if (state.next.length === 0 || peekForward === 0) {\n return {\n done: true,\n state: {\n current: Symbol[\"ITR8_NO_CURRENT\"],\n next: [],\n previous: state.previous,\n },\n };\n } else {\n const [firstOfNext, ...restOfNext] = state.next;\n\n const newState = {\n current: firstOfNext,\n next: restOfNext || [],\n previous: [state.current, ...state.previous].slice(\n 0,\n peekBackward as number,\n ),\n };\n return {\n done: false,\n value: {\n value: newState.current,\n next: newState.next,\n previous: newState.previous,\n },\n state: newState,\n };\n }\n } else {\n // NOT nextIn.done\n if (state.next.length < peekForward) {\n const newState = {\n current: state.current, // still Symbol['ITR8_NO_CURRENT'] until we have enough next values\n next: [...state.next, nextIn.value].slice(0, peekForward as number),\n previous: state.previous,\n };\n return { done: false, state: newState };\n } else {\n // the 'normal' case in the middle of a flow\n const [firstOfNext, ...restOfNext] = state.next;\n const current = peekForward === 0 ? nextIn.value : firstOfNext;\n const newState = {\n current,\n next: [...(restOfNext || []), nextIn.value].slice(\n 0,\n peekForward as number,\n ),\n previous: (state.current === Symbol[\"ITR8_NO_CURRENT\"]\n ? state.previous\n : [state.current, ...(state.previous || [])]\n ).slice(0, peekBackward as number),\n };\n return {\n done: false,\n value: {\n value: newState.current,\n next: newState.next,\n previous: newState.previous,\n },\n state: newState,\n };\n }\n }\n },\n () => ({\n // hasPrevious: false,\n previous: [],\n current: Symbol[\"ITR8_NO_CURRENT\"],\n next: [],\n // hasNext\n }),\n );\n// const peek = (amountNext: number, amountPrevious: number = 0) => {\n\n// // return (it: Iterator | AsyncIterator):Iterator | AsyncIterator => {\n// // let inputs:Array> | IteratorResult> = [];\n// // let isAsyncInput:boolean;\n// // const addInputIfNeeded = async () => {\n// // if (inputs.length < amount) {\n// // if (isAsyncInput && inputs.length > 0) await inputs[0];\n// // const next = it.next();\n// // if (isPromise(next)) {\n// // // console.log(' add another (async) input, current nr of inputs = ', inputs.length, ' < ', amount);\n// // isAsyncInput = true;\n// // next.then((n) => {\n// // if (!n.done) {\n// // // console.log(' then: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n// // addInputIfNeeded();\n// // }\n// // });\n// // }\n// // inputs.push(next);\n// // }\n// // }\n\n// // const retVal = {\n// // [Symbol.asyncIterator]: () => retVal as AsyncIterableIterator,\n// // [Symbol.iterator]: () => retVal as IterableIterator,\n// // next: () => {\n// // // console.log(' next: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n// // addInputIfNeeded();\n// // if (inputs.length > 0) {\n// // const [firstInput, ...remainingInputs] = inputs;\n// // inputs = remainingInputs;\n// // // console.log(' next: call 2 to addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n// // addInputIfNeeded();\n// // // console.log(' next: return ', firstInput);\n// // return firstInput;\n// // }\n// // return isAsyncInput\n// // ? Promise.resolve({ done: true, value: undefined }) as Promise>\n// // : { done: true, value: undefined } as IteratorResult;\n// // }\n// // };\n\n// // return retVal as any;\n// // }\n// };\n\nexport { peek };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * The reduce() method executes a user-supplied \"reducer\" callback function on each element of\n * the iterator, in order, passing in the return value from the calculation on the preceding\n * element. The final result of running the reducer across all elements of the array is a\n * single value, so the ouput iterator will only produce 1 result before finishing.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * reduce((acc, cur) => acc + cur, 0),\n * );\n * // => [ 10 ]\n * ```\n *\n * The reduce function can be an asynchronous function (in which case the resulting\n * iterator will be asynchronous regardless of the input iterator)!\n *\n * @param reducer\n * @param initialValue: value passed as 'accumulator' on the very first call to the reducer function\n *\n * @category operators/general\n */\nconst reduce = (\n reducer: (\n accumulator: TOut,\n currentValue: TIn,\n presentIndex?: number,\n ) => TOut | Promise,\n initialValue: TOut,\n) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n }\n\n const acc = state.accumulator;\n\n if (nextIn.done) {\n return { done: false, value: acc, state: { ...state, done: true } };\n }\n\n return thenable(reducer(acc, nextIn.value, state.index)).then(\n (reduced) => ({\n done: false,\n state: {\n ...state,\n index: state.index + 1,\n accumulator: reduced,\n },\n }),\n ).src;\n\n // const reduced = params.reducer(acc, nextIn.value, state.index);\n // if (isPromise(reduced)) {\n // return (async () => ({\n // done: false,\n // state: {\n // ...state,\n // index: state.index + 1,\n // accumulator: await reduced,\n // }\n // }))();\n // }\n\n // // synchronous\n // return {\n // done: false,\n // state: {\n // ...state,\n // index: state.index + 1,\n // accumulator: reduced,\n // }\n // };\n },\n () => ({ index: 0, accumulator: initialValue, done: false }),\n );\n\nexport { reduce };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Repeat the entire iterator the given amount.\n * If the amount is zero (or negative), you'll end up with an empty iterator.\n *\n * BEWARE: In order to be able to repeat everything, the entire collection must be kept in memory\n * (as opposed to repeatEach where only a single element needs to be stored).\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world' ]),\n * repeat(2)\n * ) // => [ 'hello', 'world', 'hello', 'world' ]\n * ```\n * @example\n * ```typescript\n * // creating an indentation function is easy (even if it's 0)\n * function getIndentation(indentationLevel, tabSize = 2) {\n * const singleTab = pipe(\n * itr8FromSingleValue(' '),\n * repeat(tabSize),\n * itr8ToSTring,\n * );\n * return pipe(\n * itr8FromSingleValue(singleTab)\n * repeat(indentationLevel),\n * itr8ToSTring,\n * );\n * }\n * getIndentation(3); // => ' ' (6 spaces)\n * ```\n *\n * @category operators/general\n */\nconst repeat = (count = 2) =>\n powerMap; remaining: number }>(\n (nextIn, { list, remaining }) => {\n if (remaining <= 0) {\n return { done: true };\n }\n\n if (nextIn.done) {\n return {\n done: false,\n iterable: list,\n state: { list, remaining: remaining - 1 },\n };\n }\n\n return {\n done: false,\n value: nextIn.value,\n state: { list: list.concat(nextIn.value), remaining },\n };\n },\n () => ({ list: [], remaining: count - 1 }),\n );\n\nexport { repeat };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Repeat each element of the iterator for the given amount.\n * If the amount is zero (or negative), you'll end up with an empty iterator.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world' ]),\n * repeatEach(2)\n * ) // => [ 'hello', 'hello', 'world', 'world' ]\n * ```\n * @example\n * ```typescript\n * // creating an indentation function is easy (even if it's 0)\n * function getIndentation(indentationLevel, tabSize = 2) {\n * const singleTab = pipe(\n * itr8FromSingleValue(' '),\n * repeatEach(tabSize),\n * itr8ToSTring,\n * );\n * return pipe(\n * itr8FromSingleValue(singleTab)\n * repeatEach(indentationLevel),\n * itr8ToSTring,\n * );\n * }\n * getIndentation(3); // => ' ' (6 spaces)\n * ```\n *\n * @category operators/general\n */\nconst repeatEach = (count = 2) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n }\n return {\n done: false,\n iterable: (function* () {\n for (let i = 0; i < count; i++) {\n yield nextIn.value;\n }\n })(),\n };\n },\n () => undefined,\n );\n\nexport { repeatEach };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * The runnigReduce() method executes a user-supplied \"reducer\" callback function on each element of\n * the iterator, in order, passing in the return value from the calculation on the preceding\n * element. Eaxch next call produces the result of running the reducer across all elements so far.\n * (called scan in RxJS)\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * reduce((acc, cur) => acc + cur, 0),\n * );\n * // => [ 1, 3, 6, 10 ]\n * ```\n *\n * The reduce function can be an asynchronous function (in which case the resulting\n * iterator will be asynchronous regardless of the input iterator)!\n *\n * @param reducer\n * @param initialValue: value passed as 'accumulator' on the very first call to the reducer function\n *\n * @category operators/general\n */\nconst runningReduce = (\n reducer: (\n accumulator: TOut,\n currentValue: TIn,\n presentIndex?: number,\n ) => TOut | Promise,\n initialValue: TOut,\n) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n }\n\n const acc = state.index === 0 ? initialValue : state.accumulator;\n\n if (nextIn.done) {\n return { done: true, value: acc, state };\n }\n\n return thenable(reducer(acc, nextIn.value, state.index)).then(\n (reduced) => ({\n done: false,\n value: reduced,\n state: {\n ...state,\n index: state.index + 1,\n accumulator: reduced,\n },\n }),\n ).src;\n },\n () => ({ index: 0, accumulator: initialValue }),\n );\n\nexport { runningReduce };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Skip the 'amount' first elements and return all the others unchanged.\n *\n * @param amount\n *\n * @category operators/general\n */\nconst skip = (params = 0) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n if (state < params) return { done: false, state: state + 1 };\n return { done: false, value: nextIn.value };\n },\n () => 0,\n );\n\nexport { skip };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Skip the first elements as long as the filter function returns true,\n * and return all the others unchanged.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([1, 2, 3, 4, 1, 2, 6]),\n * skipWhile(x => x < 4), // => [4, 1, 2, 6]\n * );\n * ```\n *\n * @param whileFn a fuction that returns true as long as elements should be dropped\n *\n * @category operators/general\n */\nconst skipWhile = (whileFn: (v: TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n if (state) {\n return thenable(whileFn(nextIn.value)).then(\n (keepSkipping: boolean, _isSync: boolean) =>\n keepSkipping\n ? { done: false, state }\n : { done: false, value: nextIn.value, state: false },\n ).src;\n // return { done: false, state };\n }\n return { done: false, value: nextIn.value, state: false };\n },\n () => true,\n );\n\nexport { skipWhile };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Sorts the elements (using the given sort function if provided).\n * Beware: all elements need to fit in memory before they can be sorted!\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, -2, 7, 4 ]),\n * sort(), // => [ -2, 1, 4, 7 ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ { v: 1 }, { v: -4 }, { v: 7 }, { v: 2 } ]),\n * itr8.sort((a:{ v:number }, b:{ v:number }, => a.v - b.v))\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/general\n */\nconst sort = (sortFn?: (a: TIn, b: TIn) => number) =>\n powerMap(\n (nextIn: IteratorResult, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n // sort function modifes the state, so this is not 'pure'\n return {\n done: false,\n iterable: state.list.sort(sortFn ? sortFn : undefined),\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, list: [...state.list, nextIn.value] },\n };\n // bad (but more performant?): modifying state.list instead of returning a new state!\n // state.list.push(nextIn.value);\n // return { done: false, state: { ...state, list: state.list /* [...state.list, nextIn.value] */ } };\n },\n () => ({ done: false, list: [] }),\n );\n\nexport { sort };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * like string.split => output arrays of elements and use the given parameter as a delimiter\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', '|', 'world' ]),\n * split('|'), // => [ ['hello'], ['world'] ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, true, 2, 3, true, 4 ]),\n * split(true), // => [ [1], [2,3], [4] ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst split = (delimiter) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n if (state === null) {\n return { done: true };\n }\n return { done: false, value: state, state: null };\n } else if (nextIn.value === delimiter) {\n return { done: false, value: state || [], state: [] };\n }\n return {\n done: false,\n state: [...(state === null ? [] : state), nextIn.value],\n };\n },\n () => null,\n );\n\nexport { split };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Only take 'amount' elements and then stop.\n *\n * (Beware: if the source is an Observable or a stream, it will not know that we stopped,\n * so the buffer will keep building up. The observable or stream should be closed by the user!)\n *\n * @param amount\n *\n * @category operators/general\n */\nconst take = (count = Infinity) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n if (state < count) {\n const newState = state + 1;\n return {\n done: false,\n value: nextIn.value,\n state: newState,\n isLast: newState == count,\n };\n }\n return { done: true };\n },\n () => 0,\n );\n\nexport { take };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Tap will run a function 'on the side' without while passing the iterator\n * unchanged to the next.\n *\n * @param fn\n *\n * @category operators/general\n */\nconst tap = (tapFn: (TIn) => void) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n } else {\n try {\n tapFn(nextIn.value);\n } catch (e) {\n console.warn(\"Tap function caused an exception\", e, e.stack);\n }\n return { done: false, value: nextIn.value };\n }\n },\n () => undefined,\n );\n\nexport { tap };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Only returns unique elements. It works with a simple compare, so ok for simple types like\n * numbers and strings, but for objects it will work on the reference. If you need something\n * more sophisticated, ```uniqBy(...)``` is propably what you need.\n *\n * Beware: all unique elements need to fit in memory to keep track of the ones that we already\n * have seen!\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, -2, 7, 4, -2, -2, 4, 1 ]),\n * uniq(), // => [ 1, -2, 7, 4 ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst uniq = () =>\n powerMap>(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n } else if (state.has(nextIn.value)) {\n return { done: false, state };\n }\n const newState = new Set(state);\n newState.add(nextIn.value);\n return { done: false, value: nextIn.value, state: newState };\n },\n () => new Set([]),\n );\n\nexport { uniq };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Only returns unique elements by comparing the result of the mapping function applied\n * to the element.\n * Beware: all mapped elements need to fit in memory to keep track of the ones that we already\n * have seen!\n *\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ { id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 4 }, { id: 3 } ])\n * itr8.uniqBy((a:{ id:number }) => id ) // => [ [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ];\n * );\n * ```\n *\n * @param mapFn\n *\n * @category operators/general\n */\nconst uniqBy = (mapFn: (v: TIn) => TMapFn) =>\n powerMap>(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n const hash = mapFn(nextIn.value);\n if (state.has(hash)) {\n return { done: false, state };\n }\n const newState = new Set(state);\n newState.add(hash);\n return { done: false, value: nextIn.value, state: newState };\n },\n () => new Set([]),\n );\n\nexport { uniqBy };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * The zip() operator outputs tuples containing 1 element from the first and\n * one element from the second iterator. The first iterator is leading, so when\n * the first iterator is done, the output iterator is done. When the second iterator\n * is 'shorter', the tuples will contain undefined as the second element.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * zip(itr8FromArray([ 'a', 'b', 'c', 'd' ]), // => [ [1, 'a'], [2, 'b'], [3, 'c'], [4, 'd' ] ]\n * );\n * ```\n *\n * @param secondIterator\n *\n * @category operators/general\n */\nconst zip = (secondIterator: Iterator | AsyncIterator) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n }\n\n return thenable(secondIterator.next()).then((secondNext) => ({\n done: false,\n value: [nextIn.value, (secondNext as IteratorResult).value],\n })).src;\n\n // const secondNext = secondIterator.next();\n // if (isPromise(secondNext)) {\n // return (async () => ({\n // done: false,\n // value: [nextIn.value, (await secondNext as IteratorResult).value],\n // }))();\n // }\n\n // // synchronous\n // return {\n // done: false,\n // value: [nextIn.value, (secondNext as IteratorResult).value],\n // };\n },\n () => undefined,\n );\n\nexport { zip };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output the average.\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,100),\n * average(), // => [ 50 ]\n * );\n * ```\n *\n * @param it\n * @param amount\n *\n * @category operators/numeric\n */\nconst average = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return {\n done: false,\n value: state.sum / state.count,\n state: { ...state, done: true },\n };\n const newCount = state.count + 1;\n const newSum = state.sum + nextIn.value;\n return { done: false, state: { ...state, count: newCount, sum: newSum } };\n },\n () => ({ done: false, count: 0, sum: 0 }),\n );\n\nexport { average };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output a single thing which is the highest of all values.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 7, 4 ]),\n * total(), // => [ 7 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst max = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.max,\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, max: Math.max(state.max, nextIn.value) },\n };\n },\n () => ({ done: false, max: -Infinity }),\n );\n\nexport { max };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output a single thing which is the lowest of all values.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, -2, 7, 4 ]),\n * total(), // => [ -2 ]\n * );\n * ```\n * @param amount\n *\n * @category operators/numeric\n */\nconst min = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.min,\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, min: Math.min(state.min, nextIn.value) },\n };\n },\n () => ({ done: false, min: Infinity }),\n );\n\nexport { min };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output the percentile(x)\n * It is simply using the nearest-rank method,\n * cfr. [Wikipedia](https://en.wikipedia.org/wiki/Percentile#Calculation_methods)\n * but it will only keep an ordered list of the n largest elements so far, which means that\n * computing the 90th percentile only needs to keep 10% of all the values seen in memory,\n * but the 50th percentile needs a buffer of 50% of all values.\n *\n * Various 'streaming' implementations exist, but they are more complex, so ... maybe later.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,100),\n * percentile(95), // => [ 95 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst percentile = (percentage: number) =>\n powerMap<\n number,\n number,\n { done: boolean; count: number; topArray: number[] }\n >(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return {\n done: false,\n value: state.topArray[0],\n state: { ...state, done: true },\n };\n const newCount = state.count + 1;\n const newTopArraySize =\n Math.floor(((100 - percentage) / 100) * newCount) + 1;\n const newTopArray = [...state.topArray, nextIn.value];\n newTopArray.sort((a, b) => a - b);\n while (newTopArraySize < newTopArray.length) {\n newTopArray.shift();\n }\n // console.log('value', nextIn.value, 'percentage', percentage, 'count', state.count, 'newTopArraySize', newTopArraySize, 'state.topArray', state.topArray);\n return {\n done: false,\n state: { ...state, count: newCount, topArray: newTopArray },\n };\n },\n () => ({ done: false, count: 0, topArray: [] }),\n );\n\nexport { percentile };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * On every item, output the average so far\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,10),\n * runningAverage(), // => [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]\n * );\n * ```\n *\n * @param it\n * @param amount\n *\n * @category operators/numeric\n */\nconst runningAverage = () =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n const newCount = state.count + 1;\n const newSum = state.sum + nextIn.value;\n return {\n done: false,\n state: { ...state, count: newCount, sum: newSum },\n value: newSum / newCount,\n };\n },\n () => ({ done: false, count: 0, sum: 0 }),\n );\n\nexport { runningAverage };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * On every item, output the percentile(x) so far\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,10),\n * percentile(50), // => [ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst runningPercentile = (percentage: number) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n const newCount = state.count + 1;\n const newTopArraySize =\n Math.floor(((100 - percentage) / 100) * newCount) + 1;\n const newTopArray = [...state.topArray, nextIn.value];\n newTopArray.sort((a, b) => a - b);\n while (newTopArraySize < newTopArray.length) {\n newTopArray.shift();\n }\n // console.log('value', nextIn.value, 'percentage', percentage, 'count', state.count, 'newTopArraySize', newTopArraySize, 'state.topArray', state.topArray);\n return {\n done: false,\n state: { ...state, count: newCount, topArray: newTopArray },\n value: newTopArray[0],\n };\n },\n () => ({ count: 0, topArray: [] }),\n );\n\nexport { runningPercentile };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * On every item, output the total so far.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * runningTotal(), // => [ 1, 3, 6, 10 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst runningTotal = () =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n const newTotal = state + nextIn.value;\n return { done: false, value: newTotal, state: newTotal };\n },\n () => 0,\n );\n\nexport { runningTotal };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output a single thing containing the sum of all values.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * total(), // => [ 10 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst total = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.total,\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, total: state.total + nextIn.value },\n };\n },\n () => ({ done: false, total: 0 }),\n );\n\nexport { total };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * The input must be a stream of characters or strings,\n * and the output will be 1 string for each line.\n * \\n is used as the default line separator, but you can pass any string as a parameter\n * to be used as the line separator!\n *\n * @example\n * ```typescript\n * // simplest case: an iterator of single characters\n * pipe(\n * itr8FromArray([ 'h', 'e', 'l', 'l', 'o', '\\n', 'w', 'o', 'r', 'l', 'd' ]),\n * lineByLine(), // => [ 'hello', 'world' ]\n * );\n *\n * // second case: an iterator of string chunks\n * pipe(\n * itr8FromArray(['Hel', 'lo\\nWorld\\n\\nGo', 'od', 'by', 'e', '\\nSpace', '!']),\n * lineByLine(), // => ['Hello', 'World', '', 'Goodbye', 'Space!'];\n * );\n *\n * // thrid case: the newline separator is something else than \\n\n * pipe(\n * itr8FromArray(['Hel', 'lo
>World

Go', 'od', 'by', 'e', '
Space', '!']),\n * lineByLine(), // => ['Hello', 'World', '', 'Goodbye', 'Space!'];\n * );\n * ```\n * @param {string} separator: the string that will be considered the newline sequence\n * @category operators/strings\n */\nconst lineByLine = (splitBy = \"\\n\") =>\n powerMap(\n (nextIn, { done, buffer }) => {\n if (nextIn.done) {\n if (done) {\n return { done: true, state: { done: true, buffer: \"\" } };\n } else {\n return {\n done: false,\n value: buffer,\n state: { done: true, buffer: \"\" },\n };\n }\n } else {\n const lines = nextIn.value.split(splitBy as string);\n if (lines.length === 1) {\n return {\n done: false,\n state: { done: false, buffer: buffer + lines[0] },\n };\n } else if (lines.length === 2) {\n return {\n done: false,\n value: buffer + lines[0],\n state: { done: false, buffer: lines[1] },\n };\n } else {\n return {\n done: false,\n iterable: [buffer + lines[0], ...lines.slice(1, -1)],\n state: { done: false, buffer: lines[lines.length - 1] },\n };\n }\n }\n },\n () => ({ done: false, buffer: \"\" }),\n );\n\n// Original implementation by combining other operators\n// const lineByLine = () => compose(\n// stringToChar(),\n// split('\\n'),\n// map(x => x.reduce((acc, cur) => acc + cur, '')),\n// );\n\nexport { lineByLine };\n", "import { itr8FromString } from \"../../interface/itr8FromString.js\";\nimport { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Takes all strings from the input and outputs them as single characters\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world' ]),\n * stringToChar(), // => [ 'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd' ]\n * );\n * ```\n *\n * @category operators/strings\n */\nconst stringToChar = () =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n }\n return {\n done: false,\n iterable: itr8FromString(nextIn.value),\n };\n },\n () => undefined,\n );\n\nexport { stringToChar };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Mainly useful on async iterators (for example generated from a stream of events), but see below for other options.\n *\n * Wait for x milliseconds of 'no events' before firing one.\n * So an event will either not be handled (busy period),\n * or handled after the calm period (so with a delay of x milliseconds)\n *\n * The second parameter can be used if the timestamps can be calculated from the values on the input iterator\n * (by default Date.now() will be used).\n * This makes it possible to use this operator on synchronous iterators as well!\n *\n * @example\n * ```typescript\n * // imagine a stream of values fired at this pace onto an asyncIterator called itIn:\n * // 1, wait 10ms, 2, 3, wait 30ms, 4, wait 10ms, 5, wait 10ms, 6, 7, 8, 9, wait 40ms, 10\n * const result = await pipe(itIn, debounce(20), itr8ToArray);\n * // => [1, 4, 10]\n *\n * const valuesWithTimestamps = [\n * { value: 1, timestamp: 0 },\n * { value: 2, timestamp: 10 },\n * { value: 3, timestamp: 10 },\n * { value: 4, timestamp: 40 },\n * { value: 5, timestamp: 50 },\n * { value: 6, timestamp: 60 },\n * { value: 7, timestamp: 60 },\n * { value: 8, timestamp: 60 },\n * { value: 9, timestamp: 60 },\n * { value: 10, timestamp: 100 },\n * ];\n *\n * // or get the timestamp from the input values\n * const result = await pipe(\n * itr8FromIterable(valuesWithTimestamps),\n * debounce(20, ([_v, ts]) => ts), // debounce with function that gets timestamp from input\n * map(([v, _ts]) => v), // only keep values\n * itr8ToArray,\n * );\n * // => [1, 4, 10]\n * ```\n *\n * @category operators/timeBased\n */\nconst debounce = (\n cooldownMilliseconds: number,\n getTimestamp = (_value: TIn) => Date.now(),\n) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n const newState = getTimestamp(nextIn.value);\n const timePassed = newState - state;\n if (timePassed > cooldownMilliseconds) {\n return { done: false, value: nextIn.value, state: newState };\n }\n return { done: false, state: newState };\n },\n () => -Infinity,\n );\n\nexport { debounce };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Simply delay every element by the given nr of milliseconds.\n * (Will always produce an async iterator!).\n *\n * @category operators/timeBased\n */\nconst delay = (timeout: number) =>\n powerMap(\n (nextIn, _state) => {\n return new Promise((resolve /*, reject*/) => {\n setTimeout(() => resolve(nextIn), timeout);\n });\n },\n () => undefined,\n );\n\nexport { delay };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Mainly useful on async iterators (for example generated from a stream of events), but see below for other options.\n *\n * Only throw events at most every x milliseconds.\n *\n * So when a few events happen quickly in succession, only the first one will be handled,\n * and the next ones will be ignored until enough time (x ms) has passed with\n * the previously handled event.\n *\n * The second parameter can be used if the timestamps can be calculated from the values on the input iterator\n * (by default Date.now() will be used).\n * This makes it possible to use this operator on synchronous iterators as well!\n *\n * @example\n * ```typescript\n * // imagine a stream of values fired at this pace onto an asyncIterator called itIn:\n * // 1, wait 5ms, 2, 3, wait 15ms, 4, wait 5ms, 5, wait 5ms, 6wait 10ms, 7wait 5ms, 8\n\n * const result = await pipe(itIn, throttle(15), itr8ToArray);\n * // => [1, 4, 7]\n *\n * const valuesWithTimestamps = [\n * { value: 1, timestamp: 0 },\n * { value: 2, timestamp: 5 },\n * { value: 3, timestamp: 5 },\n * { value: 4, timestamp: 20 },\n * { value: 5, timestamp: 25 },\n * { value: 6, timestamp: 30 },\n * { value: 7, timestamp: 40 },\n * { value: 8, timestamp: 45 },\n * ];\n *\n * // or get the timestamp from the input values\n * const result = await pipe(\n * itr8FromIterable(valuesWithTimestamps),\n * throttle(15, ([_v, ts]) => ts), // throttle with function that gets timestamp from input\n * map(([v, _ts]) => v), // only keep values\n * itr8ToArray,\n * );\n * // => [1, 4, 7]\n * ```\n * @category operators/timeBased\n */\nconst throttle = (\n throttleMilliseconds: number,\n getTimestamp = (_value: TIn) => Date.now(),\n) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n const now = getTimestamp(nextIn.value);\n\n if (now - state > throttleMilliseconds) {\n return { done: false, value: nextIn.value, state: now };\n }\n return { done: false, state };\n },\n () =>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,EACE,CAACC,EAAQC,IACHD,EAAO,KACF,CAAE,KAAM,EAAK,EAEf,CACL,KAAM,GACN,SAAUE,EAAeF,EAAO,KAAK,CACvC,EAEF,IAAG,EACL,ECkBF,IAAMG,GAAW,CACfC,EACAC,EAAgBC,GAAgB,KAAK,IAAI,IAEzCC,EACE,CAACC,EAAQC,IAAU,CACjB,GAAID,EAAO,KAAM,MAAO,CAAE,KAAM,EAAK,EACrC,IAAME,EAAWL,EAAaG,EAAO,KAAK,EAE1C,OADmBE,EAAWD,EACbL,EACR,CAAE,KAAM,GAAO,MAAOI,EAAO,MAAO,MAAOE,CAAS,EAEtD,CAAE,KAAM,GAAO,MAAOA,CAAS,CACxC,EACA,IAAM,IACR,ECpDF,IAAMC,GAAcC,GAClBC,EACE,CAACC,EAAQC,IACA,IAAI,QAAcC,GAAyB,CAChD,WAAW,IAAMA,EAAQF,CAAM,EAAGF,CAAO,CAC3C,CAAC,EAEH,IAAG,EACL,EC6BF,IAAMK,GAAW,CACfC,EACAC,EAAgBC,GAAgB,KAAK,IAAI,IAEzCC,EACE,CAACC,EAAQC,IAAU,CACjB,GAAID,EAAO,KACT,MAAO,CAAE,KAAM,EAAK,EAEtB,IAAME,EAAML,EAAaG,EAAO,KAAK,EAErC,OAAIE,EAAMD,EAAQL,EACT,CAAE,KAAM,GAAO,MAAOI,EAAO,MAAO,MAAOE,CAAI,EAEjD,CAAE,KAAM,GAAO,MAAAD,CAAM,CAC9B,EACA,IAAM,IACR", - "names": ["isPromise", "p", "AsyncFunction", "thenable", "x", "newX", "args", "value", "okHandler", "retVal", "thenableFactory", "y", "cachedThenable", "firstRun", "thenResult", "okHandlerResult", "doAfter", "f", "valueOrPromise", "doAfterFactory", "doAfterObj", "forLoop", "initialStateFactory", "testBeforeEach", "afterEach", "codeToExecute", "initialState", "isSyncInit", "testResult", "isSyncTest", "_", "isSyncBody", "firstStateAfterEach", "isSyncAfterBody", "state", "compose", "first", "params", "acc", "cur", "arg", "pipe", "input", "fn1", "functionsToApply", "forEach", "handler", "options", "it", "throwCount", "maxRunningHandlers", "runningHandlers", "waitForOpenSpot", "addToRunningHandlersList", "handlerPromise", "tryHandler", "v", "errorCatcher", "e", "handlerPossiblePromise", "isPromise", "nextPromiseOrValue", "nextPromise", "handleNext", "nextValue", "next", "handlerPossiblePromiseIn", "itr8FromArray", "a", "itr8FromArrayAsync", "a", "x", "itr8FromImpureFunction", "f", "retVal", "thenable", "value", "itr8FromIterable", "it", "itr8FromSingleValue", "v", "itr8FromSingleValueAsync", "v", "itr8FromString", "s", "itr8FromIterable", "itr8FromStringAsync", "s", "x", "itr8Pushable", "bufferSize", "buffer", "currentResolve", "currentDataPromise", "createNewCurrentDataPromise", "resolve", "retVal", "value", "itr8Interval", "intervalMilliseconds", "it", "itr8Pushable", "interval", "origDone", "itr8Range", "from", "to", "step", "stepValue", "upwards", "i", "itr8RangeAsync", "from", "to", "step", "stepValue", "upwards", "i", "itr8ToArray", "iterator", "n", "isPromise", "asyncResult", "result", "nSync", "itr8ToObject", "iterator", "n", "isPromise", "asyncResult", "k", "v", "result", "nSync", "itr8ToString", "iterator", "n", "isPromise", "asyncResult", "result", "nSync", "powerMapWithoutDoAfter", "nextFn", "initialStateFactory", "operatorFunction", "itIn", "pState", "operatorState", "generateFirstReturnValIfPossible", "pipe", "doAfter", "nextIn", "curNextFnResult", "returnedIterator", "generateDoneSync", "itr8FromIterable", "currentOutputIteratorNext", "generateNextFromOutputIteratorSync", "possibleNext", "generateNextReturnValSync", "outputIteratorIsAsync", "inputIteratorIsAsync", "nextFnIsAsync", "generateDoneAsync", "generateNextFromOutputIteratorAsync", "possibleNextValueOrPromise", "isPromise", "generateNextReturnValAsync", "nextInPromiseOrValue", "curNextFnResultPromiseOrValue", "n", "nResolved", "value", "err", "transIt", "input", "iterator", "iterable", "f", "forLoop", "thenable", "_forLoopResult", "newState", "retVal", "takeWhile", "filterFn", "powerMapWithoutDoAfter", "nextIn", "_state", "thenable", "filterFnResult", "itr8ToMultiIterable", "it", "subscriberMap", "buffer", "cleanBuffer", "minIndex", "pipe", "takeWhile", "forEach", "iteratorGetter", "outIt", "index", "value", "error", "mostRecent", "initalValue", "it", "nextOut", "resolveNextOutRead", "handleInputPromise", "nextOutRead", "isPromise", "resolve", "reject", "retVal", "value", "err", "prefetch", "amount", "it", "inputs", "isAsyncInput", "addInputIfNeeded", "next", "isPromise", "n", "retVal", "firstInput", "remainingInputs", "value", "err", "parallel", "options", "transIt", "moreTransIts", "transItsCombined", "acc", "cur", "input", "inIt", "iteratorOfIterables", "outIteratorOfIterators", "itr8Pushable", "pipe", "forEach", "inElement", "itOfItsElement", "subIt", "itr8FromSingleValue", "v", "itr8ToArray", "subItElement", "iteratorOfValues", "outIterator", "callbackIt", "every", "filterFn", "powerMapWithoutDoAfter", "nextIn", "state", "thenable", "result", "some", "filterFn", "powerMapWithoutDoAfter", "nextIn", "state", "thenable", "result", "map", "mapFn", "returnIteratorResultSync", "value", "returnIteratorResultAsync", "valuePromise", "returnIteratorResult", "mapFnResult", "isPromise", "powerMapWithoutDoAfter", "nextIn", "_state", "branchAndMerge", "transIt", "moreTransIts", "it", "multiIterable", "itr8ToMultiIterable", "itInput", "itr8FromIterable", "moreTransItIterators", "pipe", "isAsync", "map", "value", "itrResultsPossiblePromises", "transItIterator", "result", "isPromise", "otherValues", "dedup", "mapFn", "powerMapWithoutDoAfter", "nextIn", "state", "valueToCompare", "thenable", "v", "filter", "filterFn", "generateNextFnResultFromFilterFnResult", "firstFilterFnResult", "nextIn", "f", "filterFnResult", "isPromise", "resultPromise", "result", "powerMapWithoutDoAfter", "_state", "flatten", "powerMapWithoutDoAfter", "nextIn", "_state", "groupPer", "groupSize", "powerMapWithoutDoAfter", "nextIn", "state", "identity", "it", "itOut", "intersperse", "intersperseThing", "powerMapWithoutDoAfter", "nextIn", "state", "peek", "peekForward", "peekBackward", "powerMapWithoutDoAfter", "nextIn", "state", "firstOfNext", "restOfNext", "newState", "reduce", "reducer", "initialValue", "powerMapWithoutDoAfter", "nextIn", "state", "acc", "thenable", "reduced", "repeat", "count", "powerMapWithoutDoAfter", "nextIn", "list", "remaining", "repeatEach", "count", "powerMapWithoutDoAfter", "nextIn", "_state", "i", "runningReduce", "reducer", "initialValue", "powerMapWithoutDoAfter", "nextIn", "state", "acc", "thenable", "reduced", "skip", "params", "powerMapWithoutDoAfter", "nextIn", "state", "skipWhile", "whileFn", "powerMapWithoutDoAfter", "nextIn", "state", "thenable", "keepSkipping", "_isSync", "sort", "sortFn", "powerMapWithoutDoAfter", "nextIn", "state", "split", "delimiter", "powerMapWithoutDoAfter", "nextIn", "state", "take", "count", "powerMapWithoutDoAfter", "nextIn", "state", "newState", "tap", "tapFn", "powerMapWithoutDoAfter", "nextIn", "_state", "e", "uniq", "powerMapWithoutDoAfter", "nextIn", "state", "newState", "uniqBy", "mapFn", "powerMapWithoutDoAfter", "nextIn", "state", "hash", "newState", "zip", "secondIterator", "powerMapWithoutDoAfter", "nextIn", "_state", "thenable", "secondNext", "average", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newSum", "max", "powerMapWithoutDoAfter", "nextIn", "state", "min", "powerMapWithoutDoAfter", "nextIn", "state", "percentile", "percentage", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newTopArraySize", "newTopArray", "b", "runningAverage", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newSum", "runningPercentile", "percentage", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newTopArraySize", "newTopArray", "b", "runningTotal", "powerMapWithoutDoAfter", "nextIn", "state", "newTotal", "total", "powerMapWithoutDoAfter", "nextIn", "state", "lineByLine", "splitBy", "powerMapWithoutDoAfter", "nextIn", "done", "buffer", "lines", "stringToChar", "powerMapWithoutDoAfter", "nextIn", "_state", "itr8FromString", "debounce", "cooldownMilliseconds", "getTimestamp", "_value", "powerMapWithoutDoAfter", "nextIn", "state", "newState", "delay", "timeout", "powerMapWithoutDoAfter", "nextIn", "_state", "resolve", "throttle", "throttleMilliseconds", "getTimestamp", "_value", "powerMapWithoutDoAfter", "nextIn", "state", "now"] + "sources": ["../src/util/index.ts", "../src/interface/forEach.ts", "../src/interface/itr8FromArray.ts", "../src/interface/itr8FromArrayAsync.ts", "../src/interface/itr8FromImpureFunction.ts", "../src/interface/itr8FromIterable.ts", "../src/interface/itr8FromSingleValue.ts", "../src/interface/itr8FromSingleValueAsync.ts", "../src/interface/itr8FromString.ts", "../src/interface/itr8FromStringAsync.ts", "../src/interface/itr8Pushable.ts", "../src/interface/itr8Interval.ts", "../src/interface/itr8Range.ts", "../src/interface/itr8RangeAsync.ts", "../src/interface/itr8ToArray.ts", "../src/interface/itr8ToObject.ts", "../src/interface/itr8ToString.ts", "../src/operators/general/powerMap.ts", "../src/operators/general/takeWhile.ts", "../src/interface/itr8ToMultiIterable.ts", "../src/operators/async/mostRecent.ts", "../src/operators/async/prefetch.ts", "../src/operators/async/parallel.ts", "../src/operators/boolean/every.ts", "../src/operators/boolean/some.ts", "../src/operators/general/map.ts", "../src/operators/general/branchAndMerge.ts", "../src/operators/general/dedup.ts", "../src/operators/general/distribute.ts", "../src/operators/general/filter.ts", "../src/operators/general/flatten.ts", "../src/operators/general/groupPer.ts", "../src/operators/general/identity.ts", "../src/operators/general/intersperse.ts", "../src/operators/general/peek.ts", "../src/operators/general/reduce.ts", "../src/operators/general/repeat.ts", "../src/operators/general/repeatEach.ts", "../src/operators/general/runningReduce.ts", "../src/operators/general/skip.ts", "../src/operators/general/skipWhile.ts", "../src/operators/general/sort.ts", "../src/operators/general/split.ts", "../src/operators/general/take.ts", "../src/operators/general/tap.ts", "../src/operators/general/uniq.ts", "../src/operators/general/uniqBy.ts", "../src/operators/general/zip.ts", "../src/operators/numeric/average.ts", "../src/operators/numeric/max.ts", "../src/operators/numeric/min.ts", "../src/operators/numeric/percentile.ts", "../src/operators/numeric/runningAverage.ts", "../src/operators/numeric/runningPercentile.ts", "../src/operators/numeric/runningTotal.ts", "../src/operators/numeric/total.ts", "../src/operators/strings/lineByLine.ts", "../src/operators/strings/stringToChar.ts", "../src/operators/timeBased/debounce.ts", "../src/operators/timeBased/delay.ts", "../src/operators/timeBased/throttle.ts"], + "sourcesContent": ["/**\n * Utility functions that are used internally, but that can be used by anyone to\n * help create operators that support both synchronous and asynchronous parameters\n * (by using thenable, forLoop or isPromise).\n *\n * @module\n */\n\n// https://www.typescriptlang.org/play?#code/MYewdgzgLgBAhgLjAVwLYCMCmAnA2gXRgF4ZcBGAGhgCYqBmKgFnwG4AoUSWdBabASzABzAsVIBycJnFVxUAO4gZcgBbZM02QDMQybONZs2W5GGBR+4GFBABJKDjg3sAHgAqAPgAUiAILZsOABPdw8ASgR7R2dQmABvNhgkmHUoPTB4XABlIIwQABsAOn4HQOd8LzD2AF8jEzMLKxLokGw3EH9AkM8vZrLWyNKnVtCIzuDYhOSYfMxYdQhkfNgSAnZp2dgwdeT5FX5ZmC8AQi8Mkj7h7EKwTAAPKEqwwoATKTD4xOnkhaWoQoADsgICozoUAG5wfLITBVL5JWrTVLpFKYRbLGpGYymcyWMAAKhScGEmC80Dg2CgSDQWGwVEwYBe1IwOA+U2S-C0R3JlJgLhgDJebPh3x02COmxg-DEPKgLClfJIgvl-AA1Krhd8tTAgvxMPkXlKdlrEclqgL8hBMJ9tTAxRK5gqSLKVTAPErGSqALRezW25K6-WG-jG76mhFsWpsAD00ZgnAgBUwhXyICEXlwhSzgRJXgYAHYwvg4bH4+BE7MU2mM1nCjmhKSAKwUahFuFGUsJpNV9OXZztcZBLw2KL9bA+MKT9gccuwPpieukhgATnbUCCAOtbjcOYgL2QwBw7lsYAobgA8sgoB4xL0hs5Bi1XG4Tx4qLWARS4KgIAh4GAgg+Igb1HK53Eva9pwTWBUDgAEEG3Xd90PVxiSCCg0JvEh6lxcBCTvR8xxcFAWWwN87TABAvDuBA0KAm86JtZJJVuB4TzEEobnuR44WmPYDlJY5WKgE9XneJitUDA0KLObjRMhaFYVDaZhPYi5-mEypQ1qKNoJgWCAWoBCd2JPcDyPNCMIArCjhKQiwJI2lyK0SjqNogD6P-QDiBvdkkmRbAMj875hL-SofIk-09NU84pQ07itJFW09OweznAAJTRP5iJpHAbOC-1kgUmE-xc2S2LACEoRhMIKCSwqYDeW4-xisTbjqhqYHDf0AoybBlLNEVzTgCAYFAmJHLyyMjD0rQDlKYykPM1CAKsoIbJwxoCVsqlxpGTCqBcqiaMY4CYHQEAk2JP0khYuTYs4zTeN2fZZhOVqmthSLpk5I4yta4rYRu-0pMNAHqswAaI1tGKOPih5EumHSZtnGAQC0LQrSpRDTOQizVswsRNrxfC7L2lb1qob9dDAKlJuwYG7oquGuIR57bsdUBTFKMQAAZQ34t6hPutqvoK5IudpnAxElnnVRgMgoalLkvFl6WGNQGmoGB21QZgcHFKV7qVPulmnu06aZy4GZ+FQOyccgPGKbWjacS20ndvvfbrKpzXueZWlGcdWH1NZnjQ0lNXxRIfmRUFwSPvE8WkijmWtel+XFfqpJftV9PxRcEhqe5nXtT1g2YSN7P9dN0PzaGy2YzjYm8JgAF+E3Lxa1wEB4IdsyUKp7AhDQBkoF-GBCDCFHrbgagifmnAvAM4c7C98c4Fqo4aPpzy7hgTOt7c3eIv3m9Wyg8tu1TXt14HAJgh8Vt2y7Ssb7vJ9766Lx0cxuZV-Jl4dAW9n4vyvm-asfZWhf0fvkW2JQAHryASAycVQgA\n\nimport { TThenable } from \"../types.js\";\n\n// THIS MIGHT BE AN ALTERNATIVE TO REMOVE THE DEPENDENCY to Node's uil/types\n////////////////////////////////////////////////////////////////////////////\n/**\n * Check whether the parameter is a promise.\n *\n * @param p\n * @returns true if p is a promise\n *\n * @category util\n */\nconst isPromise = function isPromise(p: unknown): p is Promise {\n return (\n p !== undefined &&\n p !== null &&\n Object.prototype.toString.call(p) === \"[object Promise]\"\n );\n};\n\n// import { isPromise } from 'util/types'\n\n// try {\n// // eslint-disable-next-line @typescript-eslint/no-var-requires\n// isPromise = require('util/types').isPromise;\n// } catch {\n// // ignore\n// }\n\n/**\n * Shim for allowing async function creation similar to new Function.\n *\n * Found here: https://davidwalsh.name/async-function-class\n *\n * @example\n * ```javascript\n * const fetchPage = new AsyncFunction(\"url\", \"return await fetch(url);\");\n * ```\n */\nconst AsyncFunction = Object.getPrototypeOf(async function () {\n /* empty */\n}).constructor;\n\n/**\n * (Word play on then-able an th-enable)\n *\n * This utility function makes sure that any value (Promise or otherwise)\n * will be turned into an object with a then property, so that we can write the same code\n * regardless of whether the input is sync or async, but guaranteeing that\n * if the input is sync, all operations will also be called synchronously.\n *\n * The original input object is available under the thenable(...).src property.\n *\n * After the then callback has finished, the Object's 'value' property will be set\n * to the 'resolved' value.\n *\n * @example\n * ```typescript\n * // the same code can be applied without changes to a promise or a non promise\n * // by doing it all in the then-callback\n * thenable(123)\n * .then(\n * (v) => {\n * console.log(v);\n * return getSomeOtherSyncOrAsyncVal(v);\n * }\n * )\n * .then(\n * (otherVal) => {\n * console.log(otherVal);\n * return getYetAnotherVal(v);\n * }\n * )\n * ```\n *\n * ???\n * MAYBE a better solution would be to have a function called ```doAfter(value, (value) => { your code })```\n * that checks whether it is a promise or not, and returns the result of the handler?\n * But without the pipe operator it would be a pain to chain them, unless it will return an object\n * with some properties like ```{ result, doAfter:... }```\n * or maybe thenable should always return a new object with properties ```{ src, then, finally, ... }``` so\n * that the interface resembles a promise, but if we need the actual promise or value\n * we should simply call src?\n *\n * @param x a Promise or a regular value\n * @returns an object that has a then function and a src property pointing to the original input\n * regardless whether it is a Promise or not\n *\n * @category util\n */\nconst thenable = (x: T): TThenable => {\n if (isPromise(x)) {\n // console.log(`[thenable] ASYNC: ${x}`);\n const newX = {\n src: x,\n then: (...args) => thenable(x.then(...args)),\n };\n // make sure the value gets added to this object after the promise resolves\n x.then((value) => (newX[\"value\"] = value));\n return newX;\n } else {\n // console.log(`[thenable] SYNC: ${x}`);\n if (typeof (x as any)?.then === \"function\") {\n return x as unknown as TThenable;\n } else {\n // needed, because in strict mode it is impossble to set a property\n // on a string primitive (and in non-strict mode the set value cannot be read again)\n const newX = {\n src: (x as any)?.src !== undefined ? (x as any).src : x,\n then: (okHandler: (v: unknown, isSync?: boolean) => unknown) => {\n const retVal = thenable(okHandler(x, true));\n retVal[\"value\"] = retVal.src;\n return retVal;\n },\n value: x,\n };\n return newX;\n }\n }\n};\n\n/**\n * After I created the thenable function, my code became easier, because I could write\n * the same code regardless whether the input was synchronous or asynchronous.\n * But by wrapping something with thenable, the check whether it was a Promise or not\n * was done on every invocation.\n *\n * In a library that is about iterators, we expect this to be called many times.\n * So it feels like it could make sense to create a version that 'remembers'\n * the conclusions from the first run, and that will use that knowledge in the second run\n * (assuming that every next element in an iterator will be a promise if the first was a promise\n * and vice versa)\n *\n * A few tests seemed to indicate that calling isPromise often if about 10x slower than\n * checking if a variable is true or false (or is a specific symbol), so there should be\n * gain to be made with this.\n *\n * @example\n * ```typescript\n * // instead of\n * for (x of [1, 2, 3]) {\n * thenable(x).then((v) => console.log(v));\n * }\n * // do something like\n * const cachedThenable = thenableFactory(1);\n * for (x of [1, 2, 3]) {\n * cachedThenable(x).then((v) => console.log(v))\n * }\n * ```\n *\n * @param x a simple value or a promise, for which you need to execute some code\n * @returns a thenable(...)-like function that has assumptions built-in based on the first x\n */\nconst thenableFactory = (\n y: T | Promise,\n): ((x: T | Promise) => TThenable) => {\n let cachedThenable;\n let firstRun = true;\n if (isPromise(y)) {\n // console.log(`[thenableFactory] ASYNC: ${y}`);\n // let genericThenAsync = (x: Promise, ...args) => {\n // const thenResult = x.then(...args);\n // if (firstRun) {\n // firstRun = false;\n // cachedThenable = thenableFactory(thenResult);\n // genericThenAsync = (x2: Promise, ...args) => cachedThenable(x2.then(...args));\n // }\n // return cachedThenable(thenResult);\n // };\n\n return function asyncThenable(x: Promise) {\n const newX = {\n src: x,\n then: (...args) => {\n if (firstRun) {\n firstRun = false;\n const thenResult = x.then(...args);\n cachedThenable = thenableFactory(thenResult);\n return cachedThenable(thenResult);\n }\n return cachedThenable(x.then(...args));\n },\n };\n // make sure the value gets added to this object after the promise resolves\n x.then((value) => (newX[\"value\"] = value));\n return newX;\n };\n // .bind({}); // needed for 'this' to work\n } else {\n // console.log(`[thenableFactory] SYNC: ${y}`);\n // let genericThenSync = (x: T, okHandler: (v: unknown, isSync?: boolean) => unknown) => {\n // if (firstRun) {\n // firstRun = false;\n // // console.log(`[thenableFactory] set cached thenable = ${okHandlerResult}`);\n // cachedThenable = thenableFactory(okHandlerResult);\n // // overwrite genericThenSync with a version that does not need to check anymore\n // genericThenSync = (x2: T, okHandler2: (v: unknown, isSync?: boolean) => unknown) => {\n // const retVal2 = cachedThenable(okHandler2(x2, true));\n // // console.log(`genericThenSync ${x2} -> ${retVal2.value}`);\n // retVal2[\"value\"] = retVal2.src;\n // return retVal2;\n // };\n // }\n // const retVal = cachedThenable(okHandlerResult);\n // retVal[\"value\"] = retVal.src;\n // return retVal;\n // };\n\n return function syncThenable(x: T) {\n firstRun = true;\n\n if (typeof (x as any)?.then === \"function\") {\n return x as unknown as TThenable;\n } else {\n // needed, because in strict mode it is impossble to set a property\n // on a string primitive (and in non-strict mode the set value cannot be read again)\n const newX = {\n src: (x as any)?.src !== undefined ? (x as any).src : x,\n then: (okHandler: (v: unknown, isSync?: boolean) => unknown) => {\n if (firstRun) {\n firstRun = false;\n // console.log(`[thenableFactory] set cached thenable = ${okHandlerResult}`);\n const okHandlerResult = okHandler(x, true);\n cachedThenable = thenableFactory(okHandlerResult);\n const retVal = cachedThenable(okHandlerResult);\n retVal[\"value\"] = retVal.src;\n return retVal;\n }\n const retVal = cachedThenable(okHandler(x, true));\n retVal[\"value\"] = retVal.src;\n return retVal;\n },\n value: x,\n };\n return newX;\n }\n };\n // .bind({}); // needed for 'this' to work\n }\n};\n\n/**\n * doAfter() will create another function that expects a singoe argument which could either be\n * a simple value or a promise, and doAfter will make sure that the given function is executed\n * synchronously if it's a simple value, or asynchronously after the promise resolves.\n *\n * Like thenable, but trying to avoid the creation of all the intermediate objects.\n * With our pipe function, it should be easy to use.\n *\n * @example\n * ```\n * pipe(\n * promiseOrValue,\n * doAfter((v) => { do sync or async stuff with v and return the result }),\n * doAfter((w) => { do sync or async stuff and return the result }),\n * )\n * ```\n */\nconst doAfter = (\n f: (v: TIn) => TOut | Promise,\n): ((x: TIn | Promise) => TOut | Promise) => {\n return (valueOrPromise: TIn | Promise) => {\n return isPromise(valueOrPromise)\n ? (valueOrPromise.then(f) as Promise)\n : (f(valueOrPromise) as TOut);\n };\n};\n\n/**\n * Like doAfter, but remembers whether the sync or the async route should be chosen\n * based on the first call.\n * This could speed up things by avoiding repeated isPromise calls.\n * @example\n * ```typescript\n * const incrementAfter = doAfterFactory((n) => n + 1);\n * const doubleAfter = doAfterFactory((n) => n * 2);\n *\n * for (let i = 1; i <= 1_000_000; i++) {\n * pipe(\n * i,\n * incrementAfter,\n * doubleAfter,\n * toArray,\n * );\n * }\n * ```\n * @param f\n * @returns\n */\nconst doAfterFactory = (\n f: (v: TIn) => TOut | Promise,\n): {\n doAfter: (x: TIn | Promise) => TOut | Promise;\n asyncDoAfter: (promise: Promise) => Promise;\n syncDoAfter: (value: TIn) => TOut | Promise;\n} => {\n // let first = true;\n // let isAsync;\n const doAfterObj = {\n asyncDoAfter: async (valueOrPromise: Promise) =>\n f(await valueOrPromise),\n syncDoAfter: f,\n doAfter: (valueOrPromise: TIn | Promise) => {\n if (isPromise(valueOrPromise)) {\n doAfterObj.doAfter = doAfterObj.asyncDoAfter;\n } else {\n doAfterObj.doAfter = doAfterObj.syncDoAfter;\n }\n return doAfterObj.doAfter(valueOrPromise);\n },\n };\n return doAfterObj;\n // return (valueOrPromise: TIn | Promise) => {\n // if (first) {\n // isAsync = isPromise(valueOrPromise);\n // }\n // return isAsync ? (valueOrPromise as Promise).then(f) : f(valueOrPromise as TIn);\n // };\n};\n\n/**\n * This utility function will do a for loop, synchronously if all the parts are synchronous,\n * and asynchronously otherwise.\n * This should help us to use the same code yet supporting both possible scenarios.\n *\n * @param initialStateFactory\n * @param testBeforeEach\n * @param afterEach\n * @param codeToExecute\n * @returns void | Promise\n *\n * @category util\n */\nconst forLoop = (\n initialStateFactory: () => State | Promise,\n testBeforeEach: (a: State) => boolean | Promise,\n afterEach: (a: State) => State | Promise,\n codeToExecute: (a: State) => void | Promise,\n) => {\n // if we assume that thenable will return true as the second argument of the callbacks\n // when we are still synchronous, we can write this with thenable I think\n return thenable(initialStateFactory()).then((initialState, isSyncInit) => {\n return thenable(testBeforeEach(initialState)).then(\n (testResult, isSyncTest) => {\n // this should work, both for sync and async stuff, so that we don't get the indentation-of-hell issue?\n if (testResult) {\n return thenable(codeToExecute(initialState)).then((_, isSyncBody) => {\n return thenable(afterEach(initialState)).then(\n (firstStateAfterEach, isSyncAfterBody) => {\n if (isSyncInit && isSyncTest && isSyncBody && isSyncAfterBody) {\n // everything is synchronous so we can do a synchronous for loop\n let state = firstStateAfterEach;\n while (testBeforeEach(state)) {\n codeToExecute(state);\n state = afterEach(state);\n }\n return state;\n } else {\n // naive implementation: something is asynchronous so we can to do an asychronous for loop\n // return (async () => {\n // let state = firstStateAfterEach;\n // while (await testBeforeEach(state)) {\n // await codeToExecute(state);\n // state = await afterEach(state);\n // }\n // return state;\n // })();\n\n // await on a non-promise will still break execution and turns\n // the value into Promise.resolve(...))\n // SO can we only await if it's necessary?\n // 2^3 = 8 possible (ignoring the generation of initial state) combinations\n // with and without await\n // Luckily new Function('a', 'b', 'return a + b;'); will produce a function\n // from a string and some clever guy found a way to create an AsyncFunction\n // equivalent of that!\n // So using isSyncInit, isSyncTest, isSyncBody, isSyncAfterBody to decide\n // whether a value shouldbe awaited, we can solve it like this\n return new AsyncFunction(\n \"firstStateAfterEach\",\n \"testBeforeEach\",\n \"codeToExecute\",\n \"afterEach\",\n `\n let state = firstStateAfterEach;\n while (${isSyncTest ? \"\" : \"await \"}testBeforeEach(state)) {\n ${isSyncBody ? \"\" : \"await \"}codeToExecute(state);\n state = ${\n isSyncAfterBody ? \"\" : \"await \"\n }afterEach(state);\n }\n return state;\n `,\n )(\n firstStateAfterEach,\n testBeforeEach,\n codeToExecute,\n afterEach,\n );\n }\n },\n );\n });\n } else {\n return initialState;\n }\n },\n );\n });\n};\n\n// /**\n// * A more generic pipe function that takes multiple functions as input\n// * and outputs a single function where input = input of the first function\n// * and output = output where every funtion has been applied to the output of the previous on.\n// *\n// * So itr8Pipe(f1:(x:A)=>B, f2:(x:B)=>C, f3:(x:C)=>D) returns (a:A):D => f3(f2(f1(a)))\n// *\n// * @param first\n// * @param params\n// * @returns\n// *\n// * @deprecated see compose (and pipe)\n// */\n// function itr8Pipe(fn1: (x: A) => B): (x: A) => B;\n// function itr8Pipe(fn1: (x: A) => B, fn2: (x: B) => C): (x: A) => C;\n// function itr8Pipe(\n// fn1: (x: A) => B,\n// fn2: (x: B) => C,\n// fn3: (x: C) => D\n// ): (x: A) => D;\n// function itr8Pipe(\n// fn1: (x: A) => B,\n// fn2: (x: B) => C,\n// fn3: (x: C) => D,\n// fn4: (x: D) => E\n// ): (x: A) => E;\n// /*export*/ function itr8Pipe
(\n// first: (x: A) => B,\n// ...params: Array<(any) => any>\n// ): any {\n// if (params.length === 0) {\n// return first;\n// } else {\n// return params.reduce<(any) => any>((acc, cur) => {\n// return (arg) => cur(acc(arg));\n// }, first);\n// }\n// }\n\n/**\n * A generic compose function that takes multiple functions as input\n * and outputs a single function where input = input of the first function\n * and output = output where every funtion has been applied to the output of the previous one.\n *\n * So\n * ```typescript\n * compose(f1:(x:A)=>B, f2:(x:B)=>C, f3:(x:C)=>D)\n * ```\n * will return a single unary function\n * ```typescript\n * (a:A):D => f3(f2(f1(a)))\n * ```\n *\n * @param first\n * @param params\n * @returns\n */\nfunction compose(fn1: (x: A) => B): (x: A) => B;\nfunction compose(fn1: (x: A) => B, fn2: (x: B) => C): (x: A) => C;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n): (x: A) => D;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n): (x: A) => E;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n): (x: A) => F;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n): (x: A) => G;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n): (x: A) => H;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn8: (x: G) => H,\n fn7: (x: H) => I,\n): (x: A) => I;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n fn8: (x: H) => I,\n fn9: (x: I) => J,\n): (x: A) => J;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n fn8: (x: H) => I,\n fn9: (x: I) => J,\n fn10: (x: J) => K,\n): (x: A) => K;\nfunction compose(\n fn1: (x: A) => B,\n fn2: (x: B) => C,\n fn3: (x: C) => D,\n fn4: (x: D) => E,\n fn5: (x: E) => F,\n fn6: (x: F) => G,\n fn7: (x: G) => H,\n fn8: (x: H) => I,\n fn9: (x: I) => J,\n fn10: (x: J) => K,\n ...moreFns: Array<(x: unknown) => unknown>\n): (x: A) => unknown;\nfunction compose(\n first: (x: A) => B,\n ...params: Array<(unknown) => unknown>\n): unknown {\n if (params.length === 0) {\n return first;\n } else {\n return params.reduce<(unknown) => unknown>((acc, cur) => {\n return (arg) => cur(acc(arg));\n }, first);\n }\n}\n\n/**\n * A pipe function applies the multiple functions to the first parameter\n *\n * So\n * ```typescript\n * pipe(x: A, f1:(x:A)=>B, f2:(x:B)=>C, f3:(x:C)=>D)\n * ```\n * returns the result of (a:A):D => f3(f2(f1(a)))\n *\n * @param first\n * @param params\n * @returns\n */\nfunction pipe(input: IN, fn1: (x: IN) => A): A;\nfunction pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B): B;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n): C;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n): D;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n): E;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n): F;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n): G;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n): H;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n fn9: (x: H) => I,\n): I;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n fn9: (x: H) => I,\n fn10: (x: I) => J,\n): J;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n fn2: (x: A) => B,\n fn3: (x: B) => C,\n fn4: (x: C) => D,\n fn5: (x: D) => E,\n fn6: (x: E) => F,\n fn7: (x: F) => G,\n fn8: (x: G) => H,\n fn9: (x: H) => I,\n fn10: (x: I) => J,\n ...moreFns: Array<(x: unknown) => unknown>\n): unknown;\nfunction pipe(\n input: IN,\n fn1: (x: IN) => A,\n ...functionsToApply: Array<(unknown) => unknown>\n): unknown {\n if (functionsToApply.length === 0) {\n return fn1(input);\n } else {\n const composedFn = functionsToApply.reduce<(unknown) => unknown>(\n (acc, cur) => {\n return (arg) => cur(acc(arg));\n },\n fn1,\n );\n return composedFn(input);\n }\n}\n\nexport {\n compose,\n /**\n * @deprecated Use compose(...) instead!\n */\n compose as itr8Pipe,\n pipe,\n isPromise,\n AsyncFunction,\n thenable,\n thenableFactory,\n doAfter,\n doAfterFactory,\n forLoop,\n // itr8OperatorFactory,\n};\n", "/**\n * forEach is the one that will actually start 'draining' the iterator.\n * (itr8ToArray and most other itr8To... methods as well)\n *\n * @module\n */\n\nimport { isPromise } from \"../util/index.js\";\n\n/**\n * produces a function that can be applied to an iterator and that will execute\n * the handler on each value.\n *\n * The handler can be asynchronous!\n * By default the next will only be handled when the current handler has finished.\n * If you set options.concurrency to a higher value, you are allowing multiple handlers\n * to run in parallel.\n * But the next() will already be called while the (async) handler is still handling the current\n * result, which optimizes things by not waiting for the processing to finish, before asking for\n * the next one. Instead we'll first be asking for the next one, and then start processing of the\n * current one. This will waste less time than using 'for await (... of ...)' while still\n * processing things in the expected order!\n *\n * @param handler\n * @param options: ```{ concurrency: number }``` will control how many async handler are allowed to run in parallel. Default: 1\n * @returns\n *\n * @category interface/standard\n */\nconst forEach = function (\n handler: (T) => void | Promise,\n options?: { concurrency?: number },\n): (it: Iterator | AsyncIterator) => void | Promise {\n return (it: Iterator) => {\n let throwCount = 0;\n const maxRunningHandlers = options?.concurrency || 1;\n const runningHandlers: Set> = new Set();\n const waitForOpenSpot = async () => {\n // wait for an open spot if the max amount of running handlers is reached\n if (runningHandlers.size >= maxRunningHandlers) {\n await Promise.race(runningHandlers);\n }\n };\n const addToRunningHandlersList = (handlerPromise: Promise) => {\n // add it to the running handlers list\n runningHandlers.add(handlerPromise);\n handlerPromise.finally(() => {\n runningHandlers.delete(handlerPromise);\n });\n };\n /** Make sure the handler is wrapped in try/catch in order to send the right signals to the\n * input iterator in case something goes wrong!\n *\n * Self-replacing function, depending on the very first call, if the first call returns\n * a promise, the function wil replace itself with an async version, and with a sync\n * version otherwise\n */\n let tryHandler = (v: T): void | Promise => {\n const errorCatcher = (e) => {\n if (throwCount < 1) {\n try {\n it.throw?.(e);\n } catch (throwErr) {\n // native implementation crashes?\n // console.log(v, 'ERROR WHILE THROWING', throwErr);\n }\n throwCount += 1;\n }\n };\n\n try {\n const handlerPossiblePromise = handler(v);\n if (isPromise(handlerPossiblePromise)) {\n tryHandler = (v: T) => {\n // async tryHandler\n return (handler(v) as Promise).catch(errorCatcher);\n };\n handlerPossiblePromise.catch(errorCatcher);\n return handlerPossiblePromise;\n } else {\n tryHandler = (v: T) => {\n try {\n // sync tryHandler\n handler(v) as void;\n } catch (e) {\n errorCatcher(e);\n throw e;\n }\n };\n }\n } catch (e) {\n errorCatcher(e);\n throw e;\n }\n };\n\n const nextPromiseOrValue = it.next();\n if (isPromise(nextPromiseOrValue)) {\n const nextPromise = nextPromiseOrValue;\n\n const handleNext = async (nextValue) => {\n await waitForOpenSpot();\n\n const handlerPossiblePromise = tryHandler(nextValue);\n\n if (isPromise(handlerPossiblePromise)) {\n addToRunningHandlersList(handlerPossiblePromise);\n }\n };\n return (async () => {\n let next = (await nextPromise) as IteratorResult;\n while (!next.done) {\n await handleNext(next.value);\n next = await it.next();\n }\n // wait until all remaining handlers are done before resolving the current promise!\n await Promise.all(runningHandlers);\n it.return?.(next.value);\n })();\n } else {\n let next = nextPromiseOrValue;\n if (next.done) {\n it.return?.(next.value);\n } else {\n const handlerPossiblePromise: Promise | void = tryHandler(\n next.value,\n );\n if (isPromise(handlerPossiblePromise)) {\n return (async () => {\n let handlerPossiblePromiseIn: Promise | undefined =\n handlerPossiblePromise;\n while (!next.done) {\n const handlerPromise =\n handlerPossiblePromiseIn /* only the very first time */ ||\n (tryHandler(next.value) as Promise);\n handlerPossiblePromiseIn = undefined;\n\n addToRunningHandlersList(handlerPromise);\n\n next = it.next();\n await waitForOpenSpot();\n }\n // wait until all remaining handlers are done before resolving the current promise!\n await Promise.all(runningHandlers);\n it.return?.(next.value);\n })();\n } else {\n for (next = it.next(); !next.done; next = it.next()) {\n tryHandler(next.value);\n }\n // next = it.next();\n // while (!next.done) {\n // tryHandler(next.value);\n // next = it.next();\n // // console.log('[forEach] next', next);\n // }\n it.return?.(next.value);\n }\n }\n }\n };\n};\n\nexport { forEach };\n", "/**\n * Turns an array into an Iterator\n * (itr8FromIterable is more generic, this one is mainly useful for writing tests together\n * with its async brother itr8FromArrayAsync).\n *\n * @param a an array\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromArray(a: Array): IterableIterator {\n return a[Symbol.iterator]();\n}\n\nexport { itr8FromArray };\n", "/**\n * Turns an array into an (async) Iterator. Mainly useful for testing.\n *\n * @param a an array\n * @returns an async iterator\n *\n * @category interface/standard\n */\nfunction itr8FromArrayAsync(a: Array): AsyncIterableIterator {\n return (async function* () {\n for (const x of a) {\n yield x;\n }\n })();\n}\n\nexport { itr8FromArrayAsync };\n", "import { nextTick } from \"process\";\nimport { thenable } from \"../util/index.js\";\n\n/**\n * Turns a parameterless function into an Iterator that will produce results using\n * the input function's return value. In case the function returns a promise, the result will be\n * an AsyncIterator.\n * Useful for 'impure' stuff like Math.random, or Date.now etc.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromImpureFunction(Math.random),\n * take(3),\n * itr8ToArray\n * ); // => [0.2511072995514807, 0.04918679946517224, 0.48479881173432826]\n * ```\n * @param a anything like object, string, number, ...\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromImpureFunction(\n f: () => T | Promise,\n): IterableIterator | AsyncIterableIterator {\n const retVal = {\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n next: () => thenable(f()).then((value) => ({ done: false, value })).src,\n };\n return retVal;\n}\n\nexport { itr8FromImpureFunction };\n", "/**\n * Gets a wrapped instance of the iterator OR the async iterator from any iterable (including arrays)\n * so that we can easily pipe it into the operators.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromIterable([1,2,3]),\n * map((x) => x + 100),\n * )\n * ```\n *\n * @category interface/standard\n */\nfunction itr8FromIterable(\n it: Iterable | AsyncIterable,\n): IterableIterator | AsyncIterableIterator {\n if (it[Symbol.iterator]) {\n return it[Symbol.iterator]();\n } else {\n return it[Symbol.asyncIterator]();\n }\n}\n\nexport { itr8FromIterable };\n", "/**\n * Turns a single value into an Iterator that will produce 1 result.\n * Should work for boolean, number, string, object, ...\n *\n * @param a anything like object, string, number, ...\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromSingleValue(v: any): IterableIterator {\n return (function* () {\n yield v;\n })();\n}\n\nexport { itr8FromSingleValue };\n", "/**\n * Turns a single value into an (async) Iterator that will produce 1 result.\n * Should work for boolean, number, string, object, ...\n *\n * @param a anything like object, string, number, ...\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromSingleValueAsync(v: any): AsyncIterableIterator {\n return (async function* () {\n yield v;\n })();\n}\n\nexport { itr8FromSingleValueAsync };\n", "import { itr8FromIterable } from \"./itr8FromIterable.js\";\n\n/**\n * Turns a string into an Iterator that outputs every character of the string separately.\n *\n * (but since a string is an Iterable, you can use itr8FromIterable on strings as well!)\n *\n * @param s string\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromString(s: string): IterableIterator {\n return itr8FromIterable(s) as IterableIterator;\n}\n\nexport { itr8FromString };\n", "/**\n * Turns a string into an (async) Iterator that outputs every character of\n * the string separately.\n *\n * @param s a string\n * @returns an iterator\n *\n * @category interface/standard\n */\nfunction itr8FromStringAsync(s: string): AsyncIterableIterator {\n return (async function* () {\n for (const x of s) {\n yield x;\n }\n })();\n}\n\nexport { itr8FromStringAsync };\n", "import { TPushable } from \"../types.js\";\n\n/**\n * Creates an AsyncIterableIterator, that also exposes\n * * a push(...) method that can be used to push values into it (for example based on events).\n * * a done() method that can be used to indicate that no more values will follow.\n *\n * The optional bufferSize parameter defines how large the buffer is that will hold the\n * messages until they are pulled by a next() call. The oldest messages will be\n * dropped if no one is consuming the iterator fast enough.\n *\n * If no bufferSize is specified, the buffer will keep growing indefinitely.\n *\n * @param observable\n * @returns\n *\n * @category interface/standard\n */\nfunction itr8Pushable(\n bufferSize?: number,\n): AsyncIterableIterator & TPushable {\n const buffer: any[] = [];\n\n let currentResolve;\n // let currentReject;\n let currentDataPromise;\n // let done = false;\n\n const createNewCurrentDataPromise = () => {\n currentDataPromise = new Promise((resolve /*, reject */) => {\n currentResolve = resolve;\n // currentReject = reject;\n });\n buffer.push(currentDataPromise);\n while (bufferSize !== undefined && buffer.length > bufferSize + 1) {\n // remove the oldest one from the buffer\n buffer.shift();\n }\n };\n\n createNewCurrentDataPromise();\n\n const retVal: AsyncIterableIterator & TPushable = {\n [Symbol.asyncIterator]: () => retVal,\n next: async () => {\n // if (done) {\n // return { done: true };\n // }\n if (buffer.length > 0) {\n // const [firstOfBufferPromise, ...restOfBuffer] = buffer;\n // buffer = restOfBuffer;\n const firstOfBufferPromise = buffer.shift();\n const asyncNext = await firstOfBufferPromise;\n return asyncNext;\n } else {\n throw new Error(\"[itr8FromObservable] No elements in the buffer?\");\n }\n },\n push: (value: T) => {\n currentResolve({ value });\n createNewCurrentDataPromise();\n },\n done: () => {\n currentResolve({ done: true });\n createNewCurrentDataPromise();\n // done = true;\n },\n };\n\n return retVal;\n}\n\nexport { itr8Pushable };\n", "import { TPushable } from \"../types.js\";\nimport { itr8Pushable } from \"./itr8Pushable.js\";\n\n/**\n * Returns a (pushable async) iterator that will automatically fire with the Date.now() value\n * of when it fired (= the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC).\n *\n * When you want it to stop, call the done() method of the returned iterator, and the interval\n * will be cleaned up.\n *\n * @param intervalMilliseconds\n * @returns an AsyncIterableIterator\n *\n * @category interface/standard\n */\nfunction itr8Interval(\n intervalMilliseconds: number,\n): AsyncIterableIterator & TPushable {\n const it = itr8Pushable(Infinity); // infinite buffer !!!\n const interval = setInterval(() => {\n it.push(Date.now());\n }, intervalMilliseconds);\n const origDone = it.done;\n it.done = () => {\n clearInterval(interval);\n return origDone();\n };\n return it;\n}\n\nexport { itr8Interval };\n", "/**\n * Utility function that produces an iterator producing numbers (not only integers)\n * starting and ending where you want, which is useful for trying out stuff\n * without manually having to create arrays.\n *\n * * 'from' can be higher than 'to', in which case the iterator will count down\n * * 'step' is always a positive number (but we are forgiving if it's not)\n *\n * @example\n * ```typescript\n * pipe(\n * itr8Range(0, 3)\n * itr8ToArray,\n * ) // => [0, 1, 2, 3]\n *\n * pipe(\n * itr8Range(0, 10, 3)\n * itr8ToArray,\n * ) // => [0, 3, 6, 9]\n *\n * pipe(\n * itr8Range(5, 1, 2)\n * itr8ToArray,\n * ) // => [5, 3, 1]\n * ```\n *\n * @param start start index\n * @param end end index\n * @param end step size, default = 1\n *\n * @category interface/standard\n */\nfunction itr8Range(\n from: number,\n to: number,\n step?: number,\n): IterableIterator {\n const stepValue = step !== undefined ? Math.abs(step) : 1;\n const upwards = from < to;\n return (function* () {\n if (upwards) {\n for (let i = from; i <= to; i = i + stepValue) {\n yield i;\n }\n } else {\n for (let i = from; i >= to; i = i - stepValue) {\n yield i;\n }\n }\n })();\n}\n\nexport { itr8Range };\n", "/**\n * Utility function that produces an (async) iterator\n * producing integers starting and ending where you want,\n * which is useful for trying out stuff without manually\n * having to create arrays.\n *\n * * 'from' can be higher than 'to', in which case the iterator will count down\n * * 'step' is always a positive number (but we are forgiving if it's not)\n *\n * @param start start index\n * @param end end index\n * @param end step size, default = 1\n *\n * @category interface/standard\n */\nfunction itr8RangeAsync(\n from: number,\n to: number,\n step?: number,\n): AsyncIterableIterator {\n const stepValue = step !== undefined ? Math.abs(step) : 1;\n const upwards = from < to;\n return (async function* () {\n if (upwards) {\n for (let i = from; i <= to; i = i + stepValue) {\n yield i;\n }\n } else {\n for (let i = from; i >= to; i = i - stepValue) {\n yield i;\n }\n }\n })();\n}\n\nexport { itr8RangeAsync };\n", "import { isPromise } from \"../util/index.js\";\n\n/**\n * Turns an itr8 into an array.\n *\n * @param iterator\n * @returns an array\n *\n * @category interface/standard\n */\nfunction itr8ToArray(\n iterator: Iterator | AsyncIterator,\n): Array | Promise> {\n let n = iterator.next();\n if (isPromise(n)) {\n return (async () => {\n const asyncResult: T[] = [];\n while (!(await n).done) {\n asyncResult.push((await n).value);\n n = iterator.next();\n }\n return asyncResult;\n })();\n } else {\n // return Array.from(iterator);\n const result: T[] = [];\n for (\n let nSync = n as IteratorResult;\n !nSync.done;\n nSync = iterator.next() as IteratorResult\n ) {\n result.push(nSync.value);\n }\n // let nSync = n as IteratorResult;\n // while (!nSync.done) {\n // result.push(nSync.value);\n // nSync = iterator.next() as IteratorResult;\n // }\n return result;\n }\n}\n\nexport { itr8ToArray };\n", "import { isPromise } from \"../util/index.js\";\n\n/**\n * Turns an itr8 into an object. It is like Object.fromEntries,\n * but it will work both for synchronous and asynchronous iterators\n *\n * @example\n * ```typescript\n * // synchronous, same as Object.fromEntries(...)\n * const myObj = pipe(\n * itr8FromIterable([['a', 'value of A'], ['b', 'value of B'], ['c', 'value of C']]),\n * itr8ToObject,\n * ) // => {\n * // a: 'value of A',\n * // b: 'value of B',\n * // c: 'value of C',\n * // }\n *\n * // asynchronous\n * await myObj2 = pipe(\n * itr8FromIterable([['a', 'value of A'], ['b', 'value of B'], ['c', 'value of C']]),\n * delay(100), // delay every element by 100 milliseconds\n * itr8ToObject,\n * ) // => {\n * // a: 'value of A',\n * // b: 'value of B',\n * // c: 'value of C',\n * // }\n * ```\n *\n * @param iterator\n * @returns an array\n *\n * @category interface/standard\n */\nfunction itr8ToObject(\n iterator:\n | Iterator<[TK: string | number | symbol, TV: unknown]>\n | AsyncIterator<[TK: string | number | symbol, TV: any]>,\n): Record | Promise> {\n let n = iterator.next();\n if (isPromise(n)) {\n return (async () => {\n const asyncResult: Record = {} as Record;\n while (!(await n).done) {\n const [k, v] = (await n).value;\n asyncResult[k] = v;\n n = iterator.next();\n }\n return asyncResult;\n })();\n } else {\n // return Array.from(iterator);\n const result: Record = {} as Record;\n let nSync = n as IteratorResult<[TK, TV]>;\n while (!nSync.done) {\n const [k, v] = nSync.value;\n result[k] = v;\n nSync = iterator.next() as IteratorResult<[TK, TV]>;\n }\n return result;\n }\n}\n\nexport { itr8ToObject };\n", "import { isPromise } from \"../util/index.js\";\nimport { forEach } from \"./forEach.js\";\n\n/**\n * Turns an iterator into a single string.\n * The strings will simply be 'glued' together, so if you need a separator,\n * use interperse first.\n *\n * It is the equivalent of Array.join('').\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray(['Hello', 'Goodbye']),\n * intersperse(' / '), // adds | between every 2 elements\n * itr8ToString,\n * ) // => 'Hello / Goodbye'\n *\n * const alphabet = pipe(\n * itr8Range(0, 25),\n * map((i: number) => String.fromCharCode(\"A\".charCodeAt(0) + i)),\n * itr8ToString\n * ); // => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n * ```\n *\n * @param iterator\n * @returns a string\n *\n * @category interface/standard\n */\nfunction itr8ToString(\n iterator: Iterator | AsyncIterator,\n): string | Promise {\n let n = iterator.next();\n if (isPromise(n)) {\n return (async () => {\n let asyncResult = \"\";\n while (!(await n).done) {\n asyncResult = asyncResult + (await n).value;\n n = iterator.next();\n }\n return asyncResult;\n })();\n } else {\n // return Array.from(iterator);\n let result = \"\";\n let nSync = n as IteratorResult;\n while (!nSync.done) {\n result = result + nSync.value;\n nSync = iterator.next() as IteratorResult;\n }\n return result;\n }\n}\n\nexport { itr8ToString };\n", "import { itr8FromIterable } from \"../../interface/index.js\";\nimport {\n TNextFnResult,\n TThenable,\n TTransIteratorSyncOrAsync,\n} from \"../../types.js\";\nimport {\n pipe,\n doAfter,\n forLoop,\n isPromise,\n thenable,\n thenableFactory,\n doAfterFactory,\n} from \"../../util/index.js\";\n\n/**\n * The powerMap can be used as the base for many many other operators.\n *\n * An operator is 'a function that generates a transIterator'.\n * So for example filter(...) is an operator, because when called with an argument\n * (the filter function) the result of that will be another function which is the transIterator.\n *\n * A transIterator is simply a function with an iterator as single argument which will return\n * another iterator. This way we can easily 'build a chain of mulitple transIterators'.\n * So it transforms iterators, which is why I have called it transIterator (~transducers).\n *\n * powerMap is an operator that generates a transIterator that\n * will work both on synchronous and asynchronous iterators.\n * The powerMap needs to be provided with a single function of the form:\n *\n * ```typescript\n * (nextOfPreviousIteratorInTheChain, state) => TNextFnResult | Promise<[TNextFnResult]>\n * ```\n * and another function generating an initial 'state' (not every operator needs state)\n *\n * * *nextIn* is the (resolved if async) result of a next call of the input iterator.\n * This means it will be of the form ```{ done: true }``` or ```{ done: false, value: <...> }```.\n * * The *state* parameter is used to allow operators to have state, but not all operators need this.\n * For example: a 'map' operator doesn't need state, but the 'skip' operator would need to keep\n * track of how many records have passed.\n *\n * Check the readme for some examples on how to write your own operators using 'powerMap'\n * (or check the source code as all the available operators have been built using this function).\n *\n * BEWARE: NEVER MODIFY THE STATE OBJECT (or any of its children!), ALWAYS RETURN A NEW VALUE!\n *\n * Why is the initial state not a simple value, but a function that produces the state?\n * This way, even if nextFn would modify the state, it wouldn't mess with other instances\n * of the same operator? Because if we'd like to deep clone the initial state ourselves, we might\n * end up with some complex cases when classes are involved (I hope no one who's interested in\n * this library will want to use classes as their state, because the library is more 'functional\n * programming' oriented)\n *\n * @typeParam TIn the type of values that the input iterator must produce\n * @typeParam TOut the type of values that the output iterator will produce\n * @typeParam TState the type of the state that will be passed between all iterations\n *\n * @param nextFn\n * @param initialStateFactory a function that generates the initialSate\n * @returns a function taking an iterator as input and that has an iterator as output\n *\n * @category operators/general\n */\nconst powerMap = function (\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n ) => TNextFnResult | Promise>,\n initialStateFactory: () => TState,\n): TTransIteratorSyncOrAsync {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n /** Means that we are done after this value or after finishing the currentOutputIterator */\n isLastOutputIterator: boolean;\n /** Means that we are done entirely */\n done: boolean;\n };\n\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n let nextInPromiseOrValue:\n | IteratorResult\n | Promise>\n | undefined = undefined;\n // let nextIn: IteratorResult | undefined = undefined;\n let isAsync: boolean | undefined = undefined;\n\n let isAsyncInput: boolean | undefined = undefined;\n function updateNextInPromiseOrValue() {\n nextInPromiseOrValue = itIn.next();\n if (isAsyncInput === undefined) {\n isAsyncInput = isPromise(nextInPromiseOrValue);\n isAsync = isAsync || isAsyncInput;\n }\n }\n let isAsyncNextFn: boolean | undefined = undefined;\n // let state = pState;\n\n // let currentOutputIterator: Iterator | AsyncIterator | undefined = undefined;\n let isAsyncCurrentOutputIterator: boolean | undefined = undefined;\n // let done = false;\n\n /**\n * Can/should we make this kind of recursive?\n * Figure out based on the input params whether we need to:\n * * return done because done = true\n * * return the next value of the current iterator\n * or empty the current iterator if we're at the end and call generateNextReturnVal\n * * do a call to nextFn\n * * if next = async, call generateNextReturnValAsync to handle this case\n * * set done to true if that is what it returns and call generateNextReturnVal\n * * return the value if it returns a value\n * * set current iterator if it returns an iterable and call generateNextReturnVal\n * @returns\n */\n const generateNextReturnValSync = ():\n | IteratorResult\n | Promise> => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n if (\n isAsyncCurrentOutputIterator ||\n isPromise(possibleNextValueOrPromise)\n ) {\n isAsyncCurrentOutputIterator = true;\n return generateNextReturnValAsync(\n true,\n undefined,\n possibleNextValueOrPromise,\n );\n }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n updateNextInPromiseOrValue();\n if (isAsyncInput) {\n return generateNextReturnValAsync(false);\n }\n const nextIn = nextInPromiseOrValue as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n ) as TNextFnResult;\n if (isAsyncNextFn === undefined) {\n isAsyncNextFn = isPromise(curNextFnResult);\n isAsync = isAsync || isAsyncNextFn;\n }\n if (isAsyncNextFn) {\n return generateNextReturnValAsync(false, curNextFnResult);\n }\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }\n };\n\n /**\n * Almost the same method but in case input or nextFn is async\n *\n * @param callUpdateNextInPromiseOrValue\n * @returns\n */\n const generateNextReturnValAsync = async (\n callUpdateNextInPromiseOrValue = true,\n nextFnResponse?,\n currentOutputIteratorNext?,\n ): Promise> => {\n let doUpdateNextInPromiseOrValue = callUpdateNextInPromiseOrValue;\n let alreadyKnownNextFnResponse = nextFnResponse;\n let alreadyKnownCurrentOutputIteratorNext = currentOutputIteratorNext;\n // while loop instead of calling this function recursively (call stack can become to large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n let possibleNextValueOrPromise;\n if (alreadyKnownCurrentOutputIteratorNext !== undefined) {\n possibleNextValueOrPromise = alreadyKnownCurrentOutputIteratorNext;\n alreadyKnownCurrentOutputIteratorNext = undefined; // only the first time !!!\n } else {\n possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n }\n const possibleNext = (\n isPromise(possibleNextValueOrPromise)\n ? await possibleNextValueOrPromise\n : possibleNextValueOrPromise\n ) as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to possibly call nextFn again\n if (doUpdateNextInPromiseOrValue) {\n updateNextInPromiseOrValue();\n } else {\n doUpdateNextInPromiseOrValue = true; // only possibly skip it the first time !!!\n }\n const nextIn = await nextInPromiseOrValue;\n let curNextFnResultPromiseOrValue;\n if (alreadyKnownNextFnResponse !== undefined) {\n curNextFnResultPromiseOrValue = alreadyKnownNextFnResponse;\n alreadyKnownNextFnResponse = undefined; // only use it the first time !!!\n } else {\n curNextFnResultPromiseOrValue = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n );\n }\n if (isAsyncNextFn === undefined) {\n isAsyncNextFn = isPromise(curNextFnResultPromiseOrValue);\n isAsync = isAsync || isAsyncNextFn;\n }\n const curNextFnResult = (\n isAsyncNextFn\n ? await curNextFnResultPromiseOrValue\n : curNextFnResultPromiseOrValue\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n operatorState.done = true; // make sure we keep returning done\n return { done: curNextFnResult.done, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n // return generateNextReturnValAsync();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n // return generateNextReturnValAsync();\n }\n }\n };\n\n /**\n * This method will replace itself with the right method once we know\n * in which case we are (sync, async)\n *\n * @returns {IteratorResult | Promise>}\n */\n let generateNextReturnVal = ():\n | IteratorResult\n | Promise> => {\n // VERSION without 'magic' for debugging\n return isAsync\n ? generateNextReturnValAsync()\n : generateNextReturnValSync();\n\n // VERSION that replaces generateNextReturnVal with the sync or async version\n // // if (isAsyncInput || isAsyncNextFn) {\n // // generateNextReturnVal = generateNextReturnValAsync;\n // // } else {\n // // generateNextReturnVal = generateNextReturnValSync;\n // // }\n\n // return generateNextReturnVal();\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const retVal = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: () => {\n if (isAsyncInput || isAsyncNextFn) {\n retVal.next = generateNextReturnValAsync;\n } else {\n retVal.next = generateNextReturnValSync;\n }\n return retVal.next();\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n itIn.return?.();\n return isAsyncInput || isAsyncNextFn\n ? Promise.resolve({ done: true, value })\n : { done: true, value };\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n itIn.throw?.(err);\n return isAsyncInput || isAsyncNextFn\n ? Promise.resolve({ done: true, value: undefined })\n : { done: true, value: undefined };\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n\n const transIt = (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n try {\n return operatorFunction(itIn, initialStateFactory());\n } catch (err) {\n itIn.throw?.();\n throw err;\n }\n };\n\n // let cachedValueThenable:\n // | ((x: any | Promise) => TThenable)\n // | undefined = undefined;\n\n /**\n * Experiment: we could expose the \"transNextFn\" which is similar to a transducer:\n * it is a function that transforms an existing nextFn, and by linking them all together\n * we'll get a nextFn that combines multiple oeprations meaning we only need one 'intermediate'\n * iterator. This might be more performant.\n * But that can only be done if input and output match so they can be composed.\n *\n * So instead of getting (nextIn, state, params) as input (without the state) and\n * TNextFnResult as output (without the state as well) we could create a function that\n * gets TNextFnResult as input as well (or at least a subset of all the possibilities).\n *\n * By subset I mean: maybe only when they have a value or an iterable, and not when they\n * have no value (meaning the element is skipped).\n */\n transIt.transNextFn = (\n input: TNextFnResult,\n ): TNextFnResult => {\n const operatorState: TOperatorState = {\n state: initialStateFactory(),\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n if (input.done === true) {\n return input;\n } else if (/* input.done === false && */ \"iterable\" in input) {\n const iterator =\n input.iterable[Symbol.iterator] || input.iterable[Symbol.asyncIterator];\n const iterable: TOut[] = [];\n const f = forLoop(\n () => iterator.next(),\n (n) => n.done !== true,\n (n) => iterator.next(),\n (nextIn: IteratorResult) => {\n thenable(\n nextFn(nextIn as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n // store the new state\n operatorState.state = curNextFnResult.state;\n\n // if it contains an iterable => iterate over it, otherwise add the value to the output array\n if (curNextFnResult.done === false && curNextFnResult.iterable) {\n // TODO support async iterable !!!\n iterable.push(...curNextFnResult.iterable);\n } else {\n iterable.push(curNextFnResult.value);\n }\n }).src;\n },\n );\n return thenable(f).then((_forLoopResult) => {\n return { done: false, iterable };\n }).src;\n } else if (/* input.done === false && */ \"value\" in input) {\n // if (cachedValueThenable === undefined) {\n // cachedValueThenable = thenableFactory(input);\n // }\n // return cachedValueThenable(input)\n // .then((input) =>\n return thenable(\n nextFn(input as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n const { newState, ...retVal } = curNextFnResult;\n // store the new state\n operatorState.state = curNextFnResult.state;\n return retVal;\n }).src;\n } else {\n // no value nor iterable in input, meaning this element should be skipped\n // so don't call any other transformers on this element\n return input;\n }\n };\n\n return transIt;\n};\n\n/**\n * An experimental version of powerMap using doAfterFactory\n * (which is proven to be faster than thenable).\n * It seems slightly faster than powerMap for synchronous code, but is slower for async.\n *\n * The most important optimization is probably the same as what doAfterFactory does:\n * do a first run in order to figure out whether the first next() call is synchronous\n * and then replace the next function by an entirely synchronous version.\n * (And maybe the async version can be written with doAfterFactory (or a for-loop))\n *\n * Consequence: an iterable can only be async in a synchronous handler if it is used the first time\n * otherwise the iterator will already be synchronous.\n *\n * how do you make the while loop work for both synchronous and asynchronous code?\n * MAYBE I should reimplement the forLoop function using doAfter, and then use the powerMap version\n * that is written using the for-loop (and drop this one)?\n *\n * @param nextFn\n * @param initialStateFactory\n * @returns\n */\nconst powerMapWithDoAfter = function <\n TIn = unknown,\n TOut = unknown,\n TState = void,\n>(\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n ) => TNextFnResult | Promise>,\n initialStateFactory: () => TState,\n): TTransIteratorSyncOrAsync {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n /** Means that we are done after this value or after finishing the currentOutputIterator */\n isLastOutputIterator: boolean;\n /** Means that we are done entirely */\n done: boolean;\n };\n\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n let nextInPromiseOrValue:\n | IteratorResult\n | Promise>\n | undefined = undefined;\n\n /**\n * This very first scroll through the loop should give us all the info we need\n * in order to establish whether the iterator will be synchronous or asynchronous.\n *\n * After this first call, we can then overwrite the next function with either a sync\n * or an async version.\n * @returns\n */\n const generateFirstReturnValIfPossible = ():\n | IteratorResult\n | Promise>\n | null\n | Promise => {\n return pipe(\n itIn.next(),\n doAfter((nextIn) => nextFn(nextIn, operatorState.state)),\n doAfter((curNextFnResult) => {\n if (\n \"state\" in curNextFnResult &&\n curNextFnResult.state !== undefined\n ) {\n operatorState.state = curNextFnResult.state;\n }\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined } as IteratorResult;\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return {\n done: false,\n value: curNextFnResult.value,\n } as IteratorResult;\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined) {\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n }\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n return pipe(\n operatorState.currentOutputIterator.next(),\n doAfter(\n (currentOutputIteratorNext): IteratorResult | null =>\n currentOutputIteratorNext.done\n ? null\n : currentOutputIteratorNext,\n ),\n );\n } else {\n return null;\n }\n }),\n ) as\n | IteratorResult\n | null\n | Promise>\n | Promise;\n };\n\n const generateNextReturnValSync = ():\n | IteratorResult\n | Promise> => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNext =\n operatorState.currentOutputIterator.next() as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = itIn.next() as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }\n };\n\n const doAfters = {\n /**\n * This one handles when we have a current output iterator that is not done.\n * It will generate the next value\n */\n currentOutputIteratorNextToNextOut: doAfterFactory<\n IteratorResult,\n IteratorResult | undefined\n >((possibleNext): IteratorResult | undefined => {\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n operatorState.done = true;\n return { done: true, value: undefined };\n }\n } else {\n return possibleNext;\n }\n }),\n /**\n * This will apply curNextFn to curNextIn\n */\n applyCurNextFnToNextIn: doAfterFactory<\n IteratorResult,\n TNextFnResult | Promise>\n >(\n (nextIn) =>\n nextFn(nextIn, operatorState.state) as TNextFnResult,\n ),\n /**\n * This part will turn the result of applying nextFn to nextIn into\n * an IteratorResult (or undefined if we need to go back to the top of\n * the while loop\n */\n handleNextFnResult: doAfterFactory<\n TNextFnResult,\n IteratorResult | undefined\n >((curNextFnResult) => {\n if (\"state\" in curNextFnResult) {\n operatorState.state = curNextFnResult.state as TState;\n }\n\n if (curNextFnResult.done) {\n operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }),\n };\n const generateNextReturnValAsync = async (): Promise<\n IteratorResult\n > => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNext = pipe(\n operatorState.currentOutputIterator.next(),\n doAfters.currentOutputIteratorNextToNextOut.doAfter,\n );\n if ((await possibleNext) !== undefined) {\n return possibleNext as\n | IteratorResult\n | Promise>;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const possibleNext = pipe(\n itIn.next(),\n doAfters.applyCurNextFnToNextIn.doAfter,\n doAfters.handleNextFnResult.doAfter,\n );\n if ((await possibleNext) !== undefined) {\n // (async () => console.log(\"Return possibleNext:\", await possibleNext))();\n return possibleNext as\n | IteratorResult\n | Promise>;\n }\n // if return has not been called, return to the top of the while loop again\n }\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const retVal = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: () => {\n const n = generateFirstReturnValIfPossible();\n const async = isPromise(n);\n if (isPromise(n)) {\n // const array = [];\n retVal.next = generateNextReturnValAsync;\n // async () => {\n // const n = await generateNextReturnValAsync();\n // if (!n) {\n // console.log(\"ASYNC next:\", n);\n // console.log(array);\n\n // console.log(\n // new Error(\"generateNextReturnValAsync returns undefined\")\n // .stack,\n // );\n // }\n // return n;\n // }\n return n.then((n2) => (n2 !== null ? n2 : retVal.next()));\n } else {\n retVal.next = generateNextReturnValSync;\n return n !== null ? n : retVal.next();\n }\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n itIn.return?.();\n return retVal.next === generateNextReturnValSync\n ? { done: true, value }\n : Promise.resolve({ done: true, value });\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n itIn.throw?.(err);\n return retVal.next === generateNextReturnValSync\n ? { done: true, value: undefined }\n : Promise.resolve({ done: true, value: undefined });\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n\n const transIt = (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n try {\n return operatorFunction(itIn, initialStateFactory());\n } catch (err) {\n itIn.throw?.();\n throw err;\n }\n };\n\n // let cachedValueThenable:\n // | ((x: any | Promise) => TThenable)\n // | undefined = undefined;\n\n /**\n * Experiment: we could expose the \"transNextFn\" which is similar to a transducer:\n * it is a function that transforms an existing nextFn, and by linking them all together\n * we'll get a nextFn that combines multiple oeprations meaning we only need one 'intermediate'\n * iterator. This might be more performant.\n * But that can only be done if input and output match so they can be composed.\n *\n * So instead of getting (nextIn, state, params) as input (without the state) and\n * TNextFnResult as output (without the state as well) we could create a function that\n * gets TNextFnResult as input as well (or at least a subset of all the possibilities).\n *\n * By subset I mean: maybe only when they have a value or an iterable, and not when they\n * have no value (meaning the element is skipped).\n */\n transIt.transNextFn = (\n input: TNextFnResult,\n ): TNextFnResult => {\n const operatorState: TOperatorState = {\n state: initialStateFactory(),\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n done: false,\n };\n\n if (input.done === true) {\n return input;\n } else if (/* input.done === false && */ \"iterable\" in input) {\n const iterator =\n input.iterable[Symbol.iterator] || input.iterable[Symbol.asyncIterator];\n const iterable: TOut[] = [];\n const f = forLoop(\n () => iterator.next(),\n (n) => n.done !== true,\n (n) => iterator.next(),\n (nextIn: IteratorResult) => {\n thenable(\n nextFn(nextIn as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n // store the new state\n operatorState.state = curNextFnResult.state;\n\n // if it contains an iterable => iterate over it, otherwise add the value to the output array\n if (curNextFnResult.done === false && curNextFnResult.iterable) {\n // TODO support async iterable !!!\n iterable.push(...curNextFnResult.iterable);\n } else {\n iterable.push(curNextFnResult.value);\n }\n }).src;\n },\n );\n return thenable(f).then((_forLoopResult) => {\n return { done: false, iterable };\n }).src;\n } else if (/* input.done === false && */ \"value\" in input) {\n // if (cachedValueThenable === undefined) {\n // cachedValueThenable = thenableFactory(input);\n // }\n // return cachedValueThenable(input)\n // .then((input) =>\n return thenable(\n nextFn(input as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n const { newState, ...retVal } = curNextFnResult;\n // store the new state\n operatorState.state = curNextFnResult.state;\n return retVal;\n }).src;\n } else {\n // no value nor iterable in input, meaning this element should be skipped\n // so don't call any other transformers on this element\n return input;\n }\n };\n\n return transIt;\n};\n\n/**\n * An experimental version of powerMap trying to learn from the lessons from\n * the powerMapWithDoAfter version\n * We'll remove doAfter again from the async version, and use simple ifs again.\n *\n * The most important optimization is probably the same as what doAfterFactory does:\n * do a first run in order to figure out whether the first next() call is synchronous\n * and then replace the next function by an entirely synchronous version.\n * (And maybe the async version can be written with doAfterFactory (or a for-loop))\n *\n * Consequence: an iterable can only be async in a synchronous handler if it is used the first time\n * otherwise the iterator will already be synchronous.\n *\n * how do you make the while loop work for both synchronous and asynchronous code?\n * MAYBE I should reimplement the forLoop function using doAfter, and then use the powerMap version\n * that is written using the for-loop (and drop this one)?\n *\n * @param nextFn\n * @param initialStateFactory\n * @returns\n */\nconst powerMapWithoutDoAfter = function <\n TIn = unknown,\n TOut = unknown,\n TState = void,\n>(\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n ) => TNextFnResult | Promise>,\n initialStateFactory: () => TState,\n): TTransIteratorSyncOrAsync {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n /** Means that we are done after this value or after finishing the currentOutputIterator */\n isLastOutputIterator: boolean;\n /** Means that we are done entirely */\n // done: boolean;\n };\n\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n // done: false,\n };\n\n /**\n * This very first scroll through the loop should give us all the info we need\n * in order to establish whether the iterator will be synchronous or asynchronous.\n *\n * After this first call, we can then overwrite the next function with either a sync\n * or an async version.\n * @returns\n */\n const generateFirstReturnValIfPossible = ():\n | IteratorResult\n | Promise>\n | null\n | Promise => {\n return pipe(\n itIn.next(),\n doAfter((nextIn) => nextFn(nextIn, operatorState.state)),\n doAfter((curNextFnResult) => {\n if (\n \"state\" in curNextFnResult &&\n curNextFnResult.state !== undefined\n ) {\n operatorState.state = curNextFnResult.state;\n }\n if (curNextFnResult.done) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n return { done: true, value: undefined } as IteratorResult;\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n }\n return {\n done: false,\n value: curNextFnResult.value,\n } as IteratorResult;\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined) {\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n }\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n return pipe(\n operatorState.currentOutputIterator.next(),\n doAfter(\n (currentOutputIteratorNext): IteratorResult | null => {\n if (currentOutputIteratorNext.done) {\n operatorState.currentOutputIterator = undefined;\n return null;\n } else {\n // Don't set it here...\n // returnedIterator.next = generateNextFromOutputIteratorAsync;\n return currentOutputIteratorNext;\n }\n },\n ),\n );\n } else {\n return null;\n }\n }),\n ) as\n | IteratorResult\n | null\n | Promise>\n | Promise;\n };\n\n const generateDoneSync: () => IteratorResult = () => ({\n done: true,\n value: undefined,\n });\n const generateNextFromOutputIteratorSync: () => IteratorResult =\n () => {\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n const possibleNext = (\n operatorState.currentOutputIterator as Iterator\n ).next() as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n return { done: true, value: undefined };\n } else {\n returnedIterator.next = generateNextReturnValSync;\n return returnedIterator.next();\n }\n } else {\n return possibleNext;\n }\n };\n\n const generateNextReturnValSync = ():\n | IteratorResult\n | Promise> => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // no running iterator, so we need to call nextFn again\n const curNextFnResult = nextFn(\n itIn.next() as IteratorResult,\n operatorState.state,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult) {\n operatorState.state = curNextFnResult.state as TState;\n }\n\n if (curNextFnResult.done) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n return { done: true, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n returnedIterator.next = generateDoneSync; // operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n returnedIterator.next = generateNextFromOutputIteratorSync;\n return returnedIterator.next();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n }\n };\n\n let outputIteratorIsAsync: boolean | undefined = undefined;\n let inputIteratorIsAsync: boolean | undefined = undefined;\n let nextFnIsAsync: boolean | undefined = undefined;\n\n const generateDoneAsync: () => Promise<\n IteratorResult\n > = async () => ({\n done: true,\n value: undefined,\n });\n const generateNextFromOutputIteratorAsync: () => Promise<\n IteratorResult\n > = async () => {\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n if (outputIteratorIsAsync === undefined)\n outputIteratorIsAsync = isPromise(possibleNextValueOrPromise);\n const possibleNext = (\n outputIteratorIsAsync\n ? await possibleNextValueOrPromise\n : possibleNextValueOrPromise\n ) as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n if (operatorState.isLastOutputIterator) {\n returnedIterator.next = generateDoneAsync; // operatorState.done = true;\n return { done: true, value: undefined };\n } else {\n returnedIterator.next = generateNextReturnValAsync;\n return returnedIterator.next();\n }\n } else {\n return possibleNext;\n }\n }\n };\n\n const generateNextReturnValAsync = async (): Promise<\n IteratorResult\n > => {\n // while loop instead of calling this function recursively (call stack can become to large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n // no running iterator, so we need to possibly call nextFn again\n const nextInPromiseOrValue = itIn.next();\n if (inputIteratorIsAsync === undefined)\n inputIteratorIsAsync = isPromise(nextInPromiseOrValue);\n const nextIn = inputIteratorIsAsync\n ? await nextInPromiseOrValue\n : nextInPromiseOrValue;\n const curNextFnResultPromiseOrValue = nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n );\n if (nextFnIsAsync === undefined)\n nextFnIsAsync = isPromise(curNextFnResultPromiseOrValue);\n\n const curNextFnResult = (\n nextFnIsAsync\n ? await curNextFnResultPromiseOrValue\n : curNextFnResultPromiseOrValue\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n if (curNextFnResult.done) {\n // make sure we keep returning done\n returnedIterator.next = generateDoneAsync; // operatorState.done = true;\n return { done: curNextFnResult.done, value: undefined };\n } else if (\"value\" in curNextFnResult) {\n if (curNextFnResult.isLast) {\n returnedIterator.next = generateDoneAsync; // operatorState.done = true;\n }\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n curNextFnResult.iterable,\n );\n operatorState.isLastOutputIterator = !!curNextFnResult.isLast;\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n returnedIterator.next = generateNextFromOutputIteratorAsync;\n return returnedIterator.next();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n // return generateNextReturnValAsync();\n }\n }\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const returnedIterator = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => returnedIterator,\n [Symbol.asyncIterator]: () => returnedIterator,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: () => {\n const n = generateFirstReturnValIfPossible();\n if (isPromise(n)) {\n return (async () => {\n // make sure all is handled before we decide what the next() function will become\n const nResolved = await n;\n returnedIterator.next =\n operatorState.currentOutputIterator === undefined\n ? generateNextReturnValAsync\n : generateNextFromOutputIteratorAsync;\n return nResolved !== null ? nResolved : returnedIterator.next();\n })();\n } else {\n returnedIterator.next =\n operatorState.currentOutputIterator === undefined\n ? generateNextReturnValSync\n : generateNextFromOutputIteratorSync;\n return n !== null ? n : returnedIterator.next();\n }\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n itIn.return?.();\n return returnedIterator.next === generateNextReturnValSync\n ? { done: true, value }\n : Promise.resolve({ done: true, value });\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n itIn.throw?.(err);\n return returnedIterator.next === generateNextReturnValSync\n ? { done: true, value: undefined }\n : Promise.resolve({ done: true, value: undefined });\n },\n };\n\n return returnedIterator as\n | IterableIterator\n | AsyncIterableIterator;\n };\n\n const transIt = (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n try {\n return operatorFunction(itIn, initialStateFactory());\n } catch (err) {\n itIn.throw?.();\n throw err;\n }\n };\n\n // let cachedValueThenable:\n // | ((x: any | Promise) => TThenable)\n // | undefined = undefined;\n\n /**\n * Experiment: we could expose the \"transNextFn\" which is similar to a transducer:\n * it is a function that transforms an existing nextFn, and by linking them all together\n * we'll get a nextFn that combines multiple oeprations meaning we only need one 'intermediate'\n * iterator. This might be more performant.\n * But that can only be done if input and output match so they can be composed.\n *\n * So instead of getting (nextIn, state, params) as input (without the state) and\n * TNextFnResult as output (without the state as well) we could create a function that\n * gets TNextFnResult as input as well (or at least a subset of all the possibilities).\n *\n * By subset I mean: maybe only when they have a value or an iterable, and not when they\n * have no value (meaning the element is skipped).\n */\n transIt.transNextFn = (\n input: TNextFnResult,\n ): TNextFnResult => {\n const operatorState: TOperatorState = {\n state: initialStateFactory(),\n currentOutputIterator: undefined,\n isLastOutputIterator: false,\n // done: false,\n };\n\n if (input.done === true) {\n return input;\n } else if (/* input.done === false && */ \"iterable\" in input) {\n const iterator =\n input.iterable[Symbol.iterator] || input.iterable[Symbol.asyncIterator];\n const iterable: TOut[] = [];\n const f = forLoop(\n () => iterator.next(),\n (n) => n.done !== true,\n (n) => iterator.next(),\n (nextIn: IteratorResult) => {\n thenable(\n nextFn(nextIn as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n // store the new state\n operatorState.state = curNextFnResult.state;\n\n // if it contains an iterable => iterate over it, otherwise add the value to the output array\n if (curNextFnResult.done === false && curNextFnResult.iterable) {\n // TODO support async iterable !!!\n iterable.push(...curNextFnResult.iterable);\n } else {\n iterable.push(curNextFnResult.value);\n }\n }).src;\n },\n );\n return thenable(f).then((_forLoopResult) => {\n return { done: false, iterable };\n }).src;\n } else if (/* input.done === false && */ \"value\" in input) {\n // if (cachedValueThenable === undefined) {\n // cachedValueThenable = thenableFactory(input);\n // }\n // return cachedValueThenable(input)\n // .then((input) =>\n return thenable(\n nextFn(input as IteratorResult, operatorState.state),\n ).then((curNextFnResult) => {\n const { newState, ...retVal } = curNextFnResult;\n // store the new state\n operatorState.state = curNextFnResult.state;\n return retVal;\n }).src;\n } else {\n // no value nor iterable in input, meaning this element should be skipped\n // so don't call any other transformers on this element\n return input;\n }\n };\n\n return transIt;\n};\n\n/**\n * EXPERIMENTAL VERSION OF THIS FUNCTION written with forLoop and thenable, which might be easier\n * to read or maintain, and could be faster...\n *\n * An operator is 'a function that generates a transIterator'.\n * So for example filter(...) is an operator, because when called with an argument\n * (the filter function) the result of that will be another function which is the transIterator.\n *\n * A transIterator is simply a function with an iterator as single argument which will return\n * another iterator. This way we can easily 'build a chain of mulitple transIterators'.\n * So it transforms iterators, which is why I have called it transIterator (~transducers).\n *\n * powerMap is a function that generates a transIteratorthat\n * will work both on synchronous and asynchronous iterators.\n * The factory needs to be provided with a single function of the form:\n *\n * ```typescript\n * (nextOfPreviousIteratorInTheChain, state) => TNextFnResult | Promise<[TNextFnResult]>\n * ```\n * and an initial state\n *\n * * nextOfPreviousIteratorInTheChain is the (resolved if async) result of a next call of the input\n * iterator. This means it will be of the form { done: true } or { done: false, value: <...> }.\n * * The state parameter is used to allow operators to have state, but not all operators need this.\n * For example: a 'map' operator doesn't need state, but the 'skip' operator would need to keep\n * track of how many records have passed.\n * * The operator params are the argument that is given to the operator function, like a number for\n * a 'take' operator, or the filter function for a 'filter' operator.\n *\n * Check the readme for some examples on how to write your own operators with powerMap\n * (or check the source code as all the available operators have been built using this function).\n *\n * BEWARE: NEVER MODIFY THE STATE OBJECT (or any of its children!), ALWAYS RETURN A NEW VALUE!\n *\n * QUESTION: would it be better to have an initial state producing function instead of an initial\n * state?\n * This way, even if nextFn would modify the state, it wouldn't mess with other instances\n * of the same operator? Because if we'd like to deep clone the initial state ourselves, we might\n * end up with some complex cases when classes are involved (I hope no one who's interested in\n * this library will want to use classes in their state, because the library is more 'functional\n * programming' oriented)\n *\n * @param nextFn\n * @param initialStateFactory a function that generates the initialSate\n * @returns a funtion taking an iterator (and optionally some argument) as input and that has an iterator as output\n *\n * @category util\n */\n// const itr8OperatorFactoryWithForLoop = function (\n// nextFn: (nextIn: IteratorResult, state: any, params: any) =>\n// TNextFnResult | Promise>,\n// initialStateFactory: () => TState,\n// ): (params: TParams) => TTransIteratorSyncOrAsync {\n// return function (params: TParams): TTransIteratorSyncOrAsync {\n// const operatorFunction = (itIn: Iterator | AsyncIterator, pState: TState) => {\n// type TOperatorFactoryState = {\n// state:TState,\n// currentOutputIterator:Iterator | AsyncIterator | undefined,\n// done:boolean,\n// };\n\n// const operatorFactoryState:TOperatorFactoryState = {\n// state: pState,\n// currentOutputIterator: undefined,\n// done: false,\n// };\n// // let nextInPromiseOrValue: IteratorResult | Promise> | undefined = undefined;\n// // // let nextIn: IteratorResult | undefined = undefined;\n// // let isAsyncInput: boolean | undefined = undefined;\n// // function updateNextInPromiseOrValue() {\n// // nextInPromiseOrValue = itIn.next();\n// // if (isAsyncInput === undefined) isAsyncInput = isPromise(nextInPromiseOrValue);\n// // }\n// // let isAsyncNextFn: boolean | undefined = undefined;\n// // // let state = pState !== undefined ? pState : initialState;\n// // let state = pState;\n\n// // let currentOutputIterator: Iterator | AsyncIterator | undefined = undefined;\n// // // let isAsyncCurrentOutputIterator:boolean | undefined = undefined;\n// // let done = false;\n\n// /**\n// * Can/should we make this kind of recursive?\n// * Figure out based on the input params whether we need to:\n// * * return done because done = true\n// * * return the next value of the current iterator\n// * or empty the current iterator if we're at the end and call generateNextReturnVal\n// * * do a call to nextFn\n// * * if next = async, call generateNextReturnValAsync to handle this case\n// * * set done to true if that is what it returns and call generateNextReturnVal\n// * * return the value if it returns a value\n// * * set current iterator if it returns an iterable and call generateNextReturnVal\n// * @returns\n// */\n// const generateNextReturnVal = () => {\n\n// forLoop| undefined }>(\n// () => (operatorFactoryState),\n// ({next}) => next !== undefined,\n// (state) => {\n// if (state.done) {\n// return { value: undefined, done: true };\n// }\n// // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n// if (state.currentOutputIterator !== undefined) {\n// return thenable(state.currentOutputIterator.next())\n// .then((v) => {\n\n// })\n// if (isPromise(possibleNextValueOrPromise)) {\n// return generateNextReturnValAsync(true, undefined, possibleNextValueOrPromise);\n// }\n// const possibleNext = possibleNextValueOrPromise as IteratorResult;\n\n// if (possibleNext.done) {\n// currentOutputIterator = undefined;\n// } else {\n// return possibleNext;\n// }\n// }\n\n// return state;\n// },\n// () => {}\n// );\n// // while loop instead of calling this function recursively (call stack can become too large)\n// while (true) {\n// if (done) {\n// return { value: undefined, done: true };\n// }\n// // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n// if (currentOutputIterator) {\n// const possibleNextValueOrPromise = currentOutputIterator.next();\n// if (isPromise(possibleNextValueOrPromise)) {\n// return generateNextReturnValAsync(true, undefined, possibleNextValueOrPromise);\n// }\n// const possibleNext = possibleNextValueOrPromise as IteratorResult;\n\n// if (possibleNext.done) {\n// currentOutputIterator = undefined;\n// } else {\n// return possibleNext;\n// }\n// }\n\n// // no running iterator, so we need to call nextFn again\n// updateNextInPromiseOrValue();\n// if (isAsyncInput) {\n// return generateNextReturnValAsync(false);\n// }\n// const nextIn = nextInPromiseOrValue as IteratorResult;\n// const curNextFnResult = nextFn(nextIn as IteratorResult, state, params) as TNextFnResult;\n// if (isAsyncNextFn === undefined) isAsyncNextFn = isPromise(curNextFnResult);\n// if (isAsyncNextFn) {\n// return generateNextReturnValAsync(false, curNextFnResult);\n// }\n// if ('state' in curNextFnResult) state = curNextFnResult.state as TState;\n\n// if (curNextFnResult.done) {\n// done = true;\n// // return generateNextReturnVal();\n// } else if ('value' in curNextFnResult) {\n// return { done: false, value: curNextFnResult.value };\n// } else if ('iterable' in curNextFnResult) {\n// if (currentOutputIterator !== undefined) throw new Error('currentOutputIterator should be undefined at this point');\n// currentOutputIterator = itr8FromIterable(curNextFnResult.iterable);\n// if (currentOutputIterator?.next === undefined) {\n// throw new Error('Error while trying to get output iterator, did you specify something that is not an Iterable to the \\'iterable\\' property? (when using a generator function, don\\'t forget to call it in order to return an IterableIterator!)');\n// }\n// // goto next round of while loop\n// // return generateNextReturnVal();\n// } else {\n// // we need to call nextIn again\n\n// // goto next round of while loop\n// // return generateNextReturnVal();\n// }\n// }\n// };\n\n// /**\n// * Almost the same method but in case input or nextFn is async\n// *\n// * @param callUpdateNextInPromiseOrValue\n// * @returns\n// */\n// const generateNextReturnValAsync = async (callUpdateNextInPromiseOrValue = true, nextFnResponse?, currentOutputIteratorNext?) => {\n// let doUpdateNextInPromiseOrValue = callUpdateNextInPromiseOrValue;\n// let alreadyKnownNextFnResponse = nextFnResponse;\n// let alreadyKnownCurrentOutputIteratorNext = currentOutputIteratorNext;\n// // while loop instead of calling this function recursively (call stack can become to large)\n// while (true) {\n// if (done) {\n// return { value: undefined, done: true };\n// }\n// // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n// if (currentOutputIterator) {\n// let possibleNextValueOrPromise;\n// if (alreadyKnownCurrentOutputIteratorNext !== undefined) {\n// possibleNextValueOrPromise = alreadyKnownCurrentOutputIteratorNext;\n// alreadyKnownCurrentOutputIteratorNext = undefined; // only the first time !!!\n// } else {\n// possibleNextValueOrPromise = currentOutputIterator.next() as any;\n// }\n// const possibleNext = (\n// isPromise(possibleNextValueOrPromise)\n// ? await possibleNextValueOrPromise\n// : possibleNextValueOrPromise\n// ) as IteratorResult;\n\n// if (possibleNext.done) {\n// currentOutputIterator = undefined;\n// } else {\n// return possibleNext;\n// }\n// }\n\n// // no running iterator, so we need to possibly call nextFn again\n// if (doUpdateNextInPromiseOrValue) {\n// updateNextInPromiseOrValue();\n// } else {\n// doUpdateNextInPromiseOrValue = true; // only possibly skip it the first time !!!\n// };\n// const nextIn = await nextInPromiseOrValue;\n// let curNextFnResultPromiseOrValue;\n// if (alreadyKnownNextFnResponse !== undefined) {\n// curNextFnResultPromiseOrValue = alreadyKnownNextFnResponse;\n// alreadyKnownNextFnResponse = undefined; // only use it the first time !!!\n// } else {\n// curNextFnResultPromiseOrValue = nextFn(nextIn as IteratorResult, state, params);\n// }\n// if (isAsyncNextFn === undefined) isAsyncNextFn = isPromise(curNextFnResultPromiseOrValue);\n// const curNextFnResult = (isAsyncNextFn ? await curNextFnResultPromiseOrValue : curNextFnResultPromiseOrValue) as TNextFnResult;\n// if ('state' in curNextFnResult) state = curNextFnResult.state as TState;\n\n// if (curNextFnResult.done) {\n// done = true;\n// // goto next round of while loop\n// // return generateNextReturnValAsync();\n// } else if ('value' in curNextFnResult) {\n// return { done: false, value: curNextFnResult.value };\n// } else if ('iterable' in curNextFnResult) {\n// if (currentOutputIterator !== undefined) throw new Error('currentOutputIterator should be undefined at this point');\n// currentOutputIterator = itr8FromIterable(curNextFnResult.iterable);\n// if (currentOutputIterator?.next === undefined) {\n// throw new Error('Error while trying to get output iterator, did you specify something that is not an Iterable to the \\'iterable\\' property? (when using a generator function, don\\'t forget to call it in order to return an IterableIterator!)');\n// }\n// // goto next round of while loop\n// // return generateNextReturnValAsync();\n// } else {\n// // we need to call nextIn again\n\n// // goto next round of while loop\n// // return generateNextReturnValAsync();\n// }\n// }\n// };\n\n// ////////////////////////////////////////////////////////////////////////////////\n// // Here is the returned IterableIterator\n// ////////////////////////////////////////////////////////////////////////////////\n// const retVal = {\n// // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n// // since we can only know whether the output will be sync or async after the first next call,\n// // we'll expose both iterator and asynciterator functions...\n// [Symbol.iterator]: () => retVal,\n// [Symbol.asyncIterator]: () => retVal,\n// // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n// next: () => {\n// if (isAsyncInput || isAsyncNextFn) {\n// return generateNextReturnValAsync();\n// }\n// return generateNextReturnVal();\n// },\n// };\n\n// return retVal as any;\n// };\n\n// return (itIn: Iterator | AsyncIterator) => operatorFunction(itIn, initialStateFactory());\n// }\n// };\n\n/**\n * UNFINISHED (some tests are failing when using this version) !!!\n *\n * EXPERIMENTAL VERSION OF THIS FUNCTION that tries to rewrite the functions\n * after we've established which parts are synchronous (input iterator next, nextFn result, ...)\n * in order to avoid checking this over and over again.\n *\n * An operator is 'a function that generates a transIterator'.\n * So for example filter(...) is an operator, because when called with an argument\n * (the filter function) the result of that will be another function which is the transIterator.\n *\n * A transIterator is simply a function with an iterator as single argument which will return\n * another iterator. This way we can easily 'build a chain of mulitple transIterators'.\n * So it transforms iterators, which is why I have called it transIterator (~transducers).\n *\n * powerMap is a function that generates transIterators that\n * will work both on synchronous and asynchronous iterators.\n * The factory needs to be provided with a single function of the form:\n *\n * ```typescript\n * (nextOfPreviousIteratorInTheChain, state, operatorParams) => TNextFnResult | Promise<[TNextFnResult]>\n * ```\n * and an initial state\n *\n * * nextOfPreviousIteratorInTheChain is the (resolved if async) result of a next call of the input\n * iterator. This means it will be of the form { done: true } or { done: false, value: <...> }.\n * * The state parameter is used to allow operators to have state, but not all operators need this.\n * For example: a 'map' operator doesn't need state, but the 'skip' operator would need to keep\n * track of how many records have passed.\n * * The operator params are the argument that is given to the operator function, like a number for\n * a 'take' operator, or the filter function for a 'filter' operator.\n *\n * Check the readme for some examples on how to write your own operators with powerMap\n * (or check the source code as all the available operators have been built using this function).\n *\n * BEWARE: NEVER MODIFY THE STATE OBJECT (or any of its children!), ALWAYS RETURN A NEW VALUE!\n *\n * QUESTION: would it be better to have an initial state producing function instead of an initial\n * state?\n * This way, even if nextFn would modify the state, it wouldn't mess with other instances\n * of the same operator? Because if we'd like to deep clone the initial state ourselves, we might\n * end up with some complex cases when classes are involved (I hope no one who's interested in\n * this library will want to use classes in their state, because the library is more 'functional\n * programming' oriented)\n *\n * @param nextFn\n * @param initialStateFactory a function that generates the initialSate\n * @returns a funtion taking an iterator (and optionally some argument) as input and that has an iterator as output\n *\n * @category util\n */\nconst itr8OperatorFactoryExperimental = function <\n TIn = unknown,\n TOut = unknown,\n TState = unknown,\n TParam1 = void,\n TParam2 = void,\n TParam3 = void,\n TParam4 = void,\n>(\n nextFn: (\n nextIn: IteratorResult,\n state: TState,\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n ) => TNextFnResult | Promise>,\n initialStateFactory: (\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n ) => TState,\n): (\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n) => TTransIteratorSyncOrAsync {\n return function (\n param1: TParam1,\n param2: TParam2,\n param3: TParam3,\n param4: TParam4,\n ...otherParams: unknown[]\n ): TTransIteratorSyncOrAsync {\n const operatorFunction = (\n itIn: Iterator | AsyncIterator,\n pState: TState,\n ) => {\n type TOperatorState = {\n state: TState;\n currentOutputIterator: Iterator | AsyncIterator | undefined;\n done: boolean;\n };\n\n const operatorState: TOperatorState = {\n state: pState,\n currentOutputIterator: undefined,\n done: false,\n };\n\n let nextInPromiseOrValue:\n | IteratorResult\n | Promise>\n | undefined = undefined;\n // let nextIn: IteratorResult | undefined = undefined;\n let isAsyncInput: boolean | undefined = undefined;\n function updateNextInPromiseOrValue() {\n nextInPromiseOrValue = itIn.next();\n if (isAsyncInput === undefined)\n isAsyncInput = isPromise(nextInPromiseOrValue);\n }\n let isAsyncNextFn: boolean | undefined = undefined;\n // let state = pState !== undefined ? pState : initialState;\n // let state = pState;\n\n // let currentOutputIterator: Iterator | AsyncIterator | undefined = undefined;\n // let isAsyncCurrentOutputIterator:boolean | undefined = undefined;\n // let done = false;\n\n /**\n * Can/should we make this kind of recursive?\n * Figure out based on the input params whether we need to:\n * * return done because done = true\n * * return the next value of the current iterator\n * or empty the current iterator if we're at the end and call generateNextReturnVal\n * * do a call to nextFn\n * * if next = async, call generateNextReturnValAsync to handle this case\n * * set done to true if that is what it returns and call generateNextReturnVal\n * * return the value if it returns a value\n * * set current iterator if it returns an iterable and call generateNextReturnVal\n * @returns\n */\n let generateNextReturnVal =\n (): // itIn:Iterator | AsyncIterator,\n // nextFn: (nextIn: IteratorResult, state: TState, param1: TParam1, param2: TParam2, param3: TParam3, param4: TParam4, ...otherParams:unknown[]) =>\n // TNextFnResult | Promise>,\n // operatorState:TOperatorState\n IteratorResult | Promise> => {\n const nextReturnVal = thenable(itIn.next()).then(\n (nextIn, isSyncInput) => {\n return thenable(\n nextFn(\n nextIn as IteratorResult,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n ),\n ).then((nextFnResult, isSyncNextFn) => {\n // nextFnResult as TNextFnResult\n if (\"state\" in nextFnResult)\n operatorState.state = nextFnResult.state as TState;\n\n let retVal;\n if (nextFnResult.done) {\n operatorState.done = true;\n // return generateNextReturnVal();\n retVal = { done: true };\n } else if (\"value\" in nextFnResult) {\n retVal = { done: false, value: nextFnResult.value };\n } else if (\"iterable\" in nextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n operatorState.currentOutputIterator = itr8FromIterable(\n nextFnResult.iterable,\n );\n if (operatorState.currentOutputIterator?.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n // return generateNextReturnVal();\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n // return generateNextReturnVal();\n }\n\n // now we can rewrite the current function in an optimized way because we know\n // which parts are async (if any) and which not\n // const newGenerateNextReturnVal = new (isSyncInput && isSyncNextFn ? Function : AsyncFunction)(\n // 'itIn',\n // 'nextFn',\n // 'operatorState',\n // `\n // // while loop instead of calling this function recursively (call stack can become too large)\n // // console.log('operatorState', operatorState);\n // while (true) {\n // if (operatorState.done) {\n // return { value: undefined, done: true };\n // }\n // // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n // if (operatorState.currentOutputIterator) {\n // const possibleNextValueOrPromise = operatorState.currentOutputIterator.next();\n // // if (isPromise(possibleNextValueOrPromise)) {\n // // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // // return { done: true };\n // // }\n // const possibleNext = possibleNextValueOrPromise;\n\n // if (possibleNext.done) {\n // operatorState.currentOutputIterator = undefined;\n // } else {\n // return possibleNext;\n // }\n // }\n\n // // no running iterator, so we need to call nextFn again\n // const nextIn = ${isSyncInput ? '' : 'await '}itIn.next();\n // const [_itIn, _nextFn, _operatorState, ...otherArgs] = [...arguments];\n // const curNextFnResult = ${isSyncNextFn ? '' : 'await '}nextFn(nextIn, operatorState.state, ...otherArgs);\n // if ('state' in curNextFnResult) operatorState.state = curNextFnResult.state as TState;\n\n // if (curNextFnResult.done) {\n // operatorState.done = true;\n // } else if ('value' in curNextFnResult) {\n // return { done: false, value: curNextFnResult.value };\n // } else if ('iterable' in curNextFnResult) {\n // if (operatorState.currentOutputIterator !== undefined) throw new Error('currentOutputIterator should be undefined at this point');\n // // operatorState.currentOutputIterator = (curNextFnResult.iterable[Symbol.iterator] || curNextFnResult.iterable[Symbol.asyncIterator])(); // itr8FromIterable(curNextFnResult.iterable);\n // if (curNextFnResult.iterable[Symbol.iterator]) {\n // operatorState.currentOutputIterator = curNextFnResult.iterable[Symbol.iterator]();\n // } else if (curNextFnResult.iterable[Symbol.asyncIterator]) {\n // operatorState.currentOutputIterator = curNextFnResult.iterable[Symbol.asyncIterator]();\n // }\n\n // if (!operatorState.currentOutputIterator || operatorState.currentOutputIterator.next === undefined) {\n // throw new Error('Error while trying to get output iterator, did you specify something that is not an Iterable to the \\\\'iterable\\\\' property? (when using a generator function, don\\\\'t forget to call it in order to return an IterableIterator!)');\n // }\n // // goto next round of while loop\n // } else {\n // // we need to call nextIn again\n // // goto next round of while loop\n // }\n // }\n // `,\n // ) as () => IteratorResult | Promise>;\n\n /**\n * Can return a value or undefined\n * @param curNextFn\n */\n const handleCurNextFnResult = (\n curNextFnResult: TNextFnResult,\n ): IteratorResult | undefined => {\n if (curNextFnResult.done) {\n operatorState.done = true;\n } else if (\"value\" in curNextFnResult) {\n return { done: false, value: curNextFnResult.value };\n } else if (\"iterable\" in curNextFnResult) {\n if (operatorState.currentOutputIterator !== undefined)\n throw new Error(\n \"currentOutputIterator should be undefined at this point\",\n );\n // operatorState.currentOutputIterator = (curNextFnResult.iterable[Symbol.iterator] || curNextFnResult.iterable[Symbol.asyncIterator])(); // itr8FromIterable(curNextFnResult.iterable);\n if (curNextFnResult.iterable[Symbol.iterator]) {\n operatorState.currentOutputIterator =\n curNextFnResult.iterable[Symbol.iterator]();\n } else if (curNextFnResult.iterable[Symbol.asyncIterator]) {\n operatorState.currentOutputIterator =\n curNextFnResult.iterable[Symbol.asyncIterator]();\n } else {\n // (!operatorState.currentOutputIterator || operatorState.currentOutputIterator.next === undefined) {\n throw new Error(\n \"Error while trying to get output iterator, did you specify something that is not an Iterable to the 'iterable' property? (when using a generator function, don't forget to call it in order to return an IterableIterator!)\",\n );\n }\n // goto next round of while loop\n } else {\n // we need to call nextIn again\n // goto next round of while loop\n }\n return undefined;\n };\n\n let newGenerateNextReturnVal;\n if (isSyncInput && isSyncNextFn) {\n // sync version\n newGenerateNextReturnVal = () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // console.log('operatorState', operatorState);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = itIn.next() as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n } else if (isSyncInput) {\n newGenerateNextReturnVal = async () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // console.log('operatorState', operatorState);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = itIn.next() as IteratorResult;\n const curNextFnResult = (await nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n )) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n } else if (isSyncNextFn) {\n newGenerateNextReturnVal = async () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // console.log('operatorState', operatorState);\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = (await itIn.next()) as IteratorResult;\n const curNextFnResult = nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n ) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n } else {\n newGenerateNextReturnVal = async () => {\n // while loop instead of calling this function recursively (call stack can become too large)\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (operatorState.done) {\n return { value: undefined, done: true };\n }\n // if an iterator of a previous nextFn call is not entirely sent yet, get the next element\n if (operatorState.currentOutputIterator) {\n const possibleNextValueOrPromise =\n operatorState.currentOutputIterator.next();\n // if (isPromise(possibleNextValueOrPromise)) {\n // if (typeof possibleNextValueOrPromise.then === 'Function') {\n // throw new Error('Async iterables inside nextFn response not supported at this time!!!');\n // // return { done: true };\n // }\n const possibleNext =\n possibleNextValueOrPromise as IteratorResult;\n\n if (possibleNext.done) {\n operatorState.currentOutputIterator = undefined;\n } else {\n return possibleNext;\n }\n }\n\n // no running iterator, so we need to call nextFn again\n const nextIn = (await itIn.next()) as IteratorResult;\n const curNextFnResult = (await nextFn(\n nextIn,\n operatorState.state,\n param1,\n param2,\n param3,\n param4,\n ...otherParams,\n )) as TNextFnResult;\n if (\"state\" in curNextFnResult)\n operatorState.state = curNextFnResult.state as TState;\n\n const r = handleCurNextFnResult(curNextFnResult);\n if (r !== undefined) {\n return r;\n }\n // if not returned, continue to the next round of the while loop\n }\n };\n }\n\n // now overwrite the function within the same context as the original function\n generateNextReturnVal = newGenerateNextReturnVal;\n\n // console.log(' ----> next return val will be', retVal);\n return retVal || generateNextReturnVal(); // generateNextReturnVal(itIn, nextFn, operatorState, param1, param2, param3, param4, ...otherParams);\n });\n },\n ).src;\n\n // console.log(' ----> next return val will be', nextReturnVal);\n return nextReturnVal;\n };\n\n ////////////////////////////////////////////////////////////////////////////////\n // Here is the returned IterableIterator\n ////////////////////////////////////////////////////////////////////////////////\n const retVal = {\n // return the current (async?) iterator to make it an iterable iterator (so we can use for ... of)\n // since we can only know whether the output will be sync or async after the first next call,\n // we'll expose both iterator and asynciterator functions...\n [Symbol.iterator]: () => retVal,\n [Symbol.asyncIterator]: () => retVal,\n // pipe: (op:TTransIteratorSyncOrAsync) => op(retVal as Iterator),\n next: ():\n | IteratorResult\n | Promise>\n | IteratorResult\n | Promise> => {\n return generateNextReturnVal(); // generateNextReturnVal(itIn, nextFn, operatorState, param1, param2, param3, param4, ...otherParams);\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n\n return (\n itIn: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator =>\n operatorFunction(\n itIn,\n initialStateFactory(param1, param2, param3, param4, ...otherParams),\n );\n };\n};\n\nexport { powerMapWithoutDoAfter as powerMap };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Only take elements as long as the filter function returns true.\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/general\n */\nconst takeWhile = (filterFn: (x: TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) return { done: true };\n\n return thenable(filterFn(nextIn.value)).then((filterFnResult) => {\n if (filterFnResult) return { done: false, value: nextIn.value };\n return { done: true };\n }).src;\n },\n () => undefined,\n );\n\nexport { takeWhile };\n", "import { takeWhile } from \"../operators/general/takeWhile.js\";\nimport { pipe } from \"../util/index.js\";\nimport { forEach } from \"./forEach.js\";\n\n/**\n * When you want to process the same iterator mutltiple times in different ways\n * (you can think of it as 'splitting the stream'),\n * it would be cool to have a way to 'subscribe' many times to the same iterator.\n * An IterableIterator returns an iterator, but that will always return the current iterator,\n * and not a new one.\n *\n * This function produces an Iterable that returns a new iterator each time [Symbol.asyncIterator]()\n * gets called, so one needs to call next on all output iterators separately to get the next element\n * of the input iterator.\n *\n * This method creates a function that turns the iterator into an Iterable that returns\n * a new iterator on calling [Symbol.asynIterator] that starts from the current element\n * (or the oldest element any of the subscribers is at?) that we are at in the source iterator.\n *\n * In order to support the fact that not all output iterators will be pulled at the same time,\n * we need to keep a cache + the position that each iterator is at.\n *\n * @todo In order to protect ourselves from 'abandoned' iterators, a timeout could be used\n * to clean them up, so the cache can be emptied up to the oldest 'active' iterator.\n *\n * @category interface/standard\n */\nfunction itr8ToMultiIterable(\n it:\n | Iterator\n | AsyncIterator /*, abandonedTimeoutMilliseconds = Infinity */,\n): AsyncIterable | Iterable {\n const subscriberMap: Map<\n AsyncIterableIterator | IterableIterator,\n number\n > = new Map();\n const buffer: Map | Promise>> =\n new Map();\n\n /** Helper to remove old elements from buffer that all current subscribers have read */\n const cleanBuffer = () => {\n const minIndex = Math.min(...subscriberMap.values());\n // Maps are iterated in insertion order !\n // ['IMPERATIVE' VERSION]\n // for (const i of buffer.keys()) {\n // if (i < minIndex) {\n // buffer.delete(i);\n // } else {\n // break;\n // }\n // }\n // ['DECLARATIVE' VERSION]\n pipe(\n buffer.keys(),\n takeWhile((i) => i < minIndex),\n forEach((i) => {\n buffer.delete(i);\n }),\n );\n };\n const iteratorGetter = () => {\n const outIt: IterableIterator | AsyncIterableIterator = {\n [Symbol.iterator]: () => outIt as IterableIterator,\n [Symbol.asyncIterator]: () => outIt as AsyncIterableIterator,\n next: () => {\n const index = subscriberMap.get(outIt) as number;\n if (!buffer.has(index)) {\n buffer.set(index, it.next());\n }\n // remove old stuff in buffer\n cleanBuffer();\n\n subscriberMap.set(outIt, index + 1);\n // if (isPromise(buffer.get(index))) {\n // return (buffer.get(index) ?? { done: true }) as Promise>;\n // } else {\n return (buffer.get(index) ?? { done: true }) as IteratorResult;\n // }\n },\n return: (value?: T) => {\n subscriberMap.delete(outIt);\n cleanBuffer();\n return { done: true, value };\n },\n throw: (error?) => {\n subscriberMap.delete(outIt);\n cleanBuffer();\n return { done: true, value: undefined };\n },\n };\n\n // add the new iterator to the subscriberMap\n subscriberMap.set(\n outIt,\n buffer.size === 0 ? 0 : Math.min(...buffer.keys()),\n );\n // TODO: set a disconnect timeout (we'll need to store the last get time, or the timeout id)\n return outIt;\n };\n\n const retVal: AsyncIterable | Iterable = {\n [Symbol.asyncIterator]: () => iteratorGetter() as AsyncIterableIterator,\n [Symbol.iterator]: () => iteratorGetter() as IterableIterator,\n };\n\n // subscriberMap.set(outIt, buffer.size > 0 ? buffer.values.next().value : 0);\n return retVal;\n}\n\nexport { itr8ToMultiIterable };\n", "import { isPromise } from \"../../util/index.js\";\n\n/**\n * Probably only useful on async iterators.\n *\n * It will turn an async iterator into an asynchronous iterator that will always return the\n * last known value, while waiting for the promise on the incoming iterator to resolve.\n *\n * Every value on the incoming iterator will be returned at least once in order to keep\n * the operator 'passive'. This operator will not actively drain the incoming iterator.\n *\n * @example\n * ```typescript\n * // input iterator\n * const it = itr8.itr8Pushable();\n * // output iterator that will always return the mostRecent value of the input iterator\n * const itOut = pipe(it, mostRecent('My initial value'));\n *\n * await sleep(1);\n * await itOut.next(); // => { value: 'My initial value' }\n * await itOut.next(); // => { value: 'My initial value' }\n * await sleep(1);\n * await itOut.next(); // => { value: 'My initial value' }\n *\n * it.push('2nd value');\n * await sleep(1);\n * await itOut.next(); // => { value: '2nd value' }\n * await itOut.next(); // => { value: '2nd value' }\n *\n * it.push('third value');\n * // sync so 'third value' promise not resolved yet at this point\n * await itOut.next(); // => { value: '2nd value' }\n * await sleep(1);\n * await itOut.next(); // => { value: 'third value' }\n * await itOut.next(); // => { value: 'third value' }\n * await sleep(1);\n * await itOut.next(); // => { value: 'third value' }\n *\n * // see evey value at least once!!!\n * it.push('fourth value');\n * it.push('fifth value');\n * // sync so 'third value' promise not resolved yet\n * await itOut.next(); // => { value: 'third value' }\n * await sleep(0);\n * await itOut.next(); // => { value: 'fourth value' }\n * await sleep(0);\n * await itOut.next(); // => { value: 'fifth value' }\n *\n * it.done();\n * // sync so 'done' promise not resolved yet\n * await itOut.next(); // => { value: 'fifth value' }\n * await sleep(1);\n * await itOut.next(); // => { done: true }\n * await itOut.next(); // => { done: true }\n * ```\n *\n * @category operators/async\n */\nconst mostRecent = (initalValue: T) => {\n return (it: Iterator | AsyncIterator): AsyncIterator => {\n let nextOut: IteratorResult = { value: initalValue };\n let resolveNextOutRead;\n\n const handleInputPromise = async () => {\n let nextOutRead: Promise | undefined = undefined;\n do {\n if (isPromise(nextOutRead)) {\n await nextOutRead;\n }\n nextOut = await it.next();\n nextOutRead = new Promise((resolve, reject) => {\n resolveNextOutRead = resolve;\n });\n } while (!nextOut.done);\n };\n\n const retVal: AsyncIterableIterator = {\n // [Symbol.iterator]: () => retVal as IterableIterator,\n [Symbol.asyncIterator]: () => retVal,\n next: async () => {\n if (resolveNextOutRead === undefined) {\n handleInputPromise();\n } else {\n resolveNextOutRead(true);\n }\n return nextOut;\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: async (value?: any) => {\n it.return?.();\n return { done: true, value };\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: async (err: any) => {\n it.throw?.(err);\n return { done: true, value: undefined };\n },\n };\n\n return retVal;\n };\n};\n\nexport { mostRecent };\n", "import { isPromise } from \"../../util/index.js\";\n\n/**\n * Probably only useful on async iterators.\n *\n * Instead of only asking for the next value of the incoming iterator when a next call comes in,\n * make sure to do one or more next calls to the incoming iterator up-front, to decrease the\n * waiting time.\n *\n * This can be used to kind of 'parallelize' the processing, while respecting the order.\n * If the order is not important, you might want to take a look a the parallel(...) operator!\n *\n * This one can be useful, when the result needs to do some I/O (for example an API get\n * or a DB fetch), and processing also takes up a certain amount of time due to I/O.\n * In this case, it makes sense to already do the next call on the incoming iterator up-front,\n * so that it will hopefully already have resolved by the time you need it for processing.\n *\n * Nothing will be done before the first next call, but after the first next call the iterator\n * will always try to have a buffer with the given amount of prefetched results (which will be\n * impossible to achieve if processing is generally faster than fetching).\n *\n * forEach actually by default acts like it has a prefetch of 1, but imagine a case where the\n * processing time can vary significantly. Then, when processing takes a long time, by prefetching\n * more than one you can make sure that there is no waiting time for the next (maybe very fast)\n * processing to start because the promises they act upon are already resolved by the time they\n * are needed.\n *\n * @category operators/async\n */\nconst prefetch = (amount: number) => {\n return (\n it: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator => {\n let inputs: Array> | IteratorResult> = [];\n let isAsyncInput: boolean;\n const addInputIfNeeded = async () => {\n if (inputs.length < amount) {\n if (isAsyncInput && inputs.length > 0) await inputs[0];\n const next = it.next();\n if (isPromise(next)) {\n // console.log(' add another (async) input, current nr of inputs = ', inputs.length, ' < ', amount);\n isAsyncInput = true;\n next.then((n) => {\n if (!n.done) {\n // console.log(' then: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n addInputIfNeeded();\n }\n });\n }\n inputs.push(next);\n }\n };\n\n const retVal = {\n [Symbol.asyncIterator]: () => retVal as AsyncIterableIterator,\n [Symbol.iterator]: () => retVal as IterableIterator,\n next: () => {\n // console.log(' next: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n addInputIfNeeded();\n if (inputs.length > 0) {\n const [firstInput, ...remainingInputs] = inputs;\n inputs = remainingInputs;\n // console.log(' next: call 2 to addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n addInputIfNeeded();\n // console.log(' next: return ', firstInput);\n return firstInput;\n }\n return isAsyncInput\n ? (Promise.resolve({ done: true, value: undefined }) as Promise<\n IteratorResult\n >)\n : ({ done: true, value: undefined } as IteratorResult);\n },\n // when the iterator is 'abandoned' (the user indicates no more next() calls will follow)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n return: (value?: any) => {\n it.return?.();\n return isAsyncInput\n ? Promise.resolve({ done: true, value })\n : { done: true, value };\n },\n // when the iterator get a throw() call\n // (the user indicates no more next() calls will follow because of an error)\n // we can do cleanup, but we also pass the message to our incoming iterator!\n throw: (err?: any) => {\n it.throw?.(err);\n return isAsyncInput\n ? Promise.resolve({ done: true, value: undefined })\n : { done: true, value: undefined };\n },\n };\n\n return retVal as IterableIterator | AsyncIterableIterator;\n };\n};\n\nexport { prefetch };\n", "import { pipe } from \"../../util/index.js\";\nimport {\n forEach,\n itr8FromSingleValue,\n itr8Pushable,\n itr8ToArray,\n} from \"../../interface/index.js\";\nimport { TPushable, TTransIteratorSyncOrAsync } from \"../../types\";\n\n/**\n * This operator should make it easy to run asynchronous transIterators in parallel, in order\n * to speed things up.\n * You can think of it as multiple lanes on a highway, but the output order of the elements\n * is still guaranteed by default! But if the order doesn't matter, you can speed up things\n * even more by allowing elements whose processing goes faster to overtake the slower ones.\n *\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502input iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \u2502\n * \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510\n * \u2502transform\u2502 \u2502transform\u2502\n * \u2502 lane 1 \u2502 \u2502 lane 2 \u2502 ...\n * \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518\n * \u2502 \u2502\n * \u2502 \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502output iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * The first argument specifies the maximum concurrency and whether the order must be respected.\n * All arguments after that are the transIterators that make up the algorithm to be run in parallel.\n *\n * 'keepOrder: false' can be useful in cases where the elements can be processed independently.\n * For example:\n * if you would model a webserver as a transIterator that turns a stream of http requests\n * into a stream of http responses, their processing can be done independently, and it would\n * make sense to respond as quickly as possible, instead of waiting for the previous request to be\n * processed first.\n *\n * This should be an ideal combination with the runInWorker operator so we can easily distribute\n * the work over the wanted amount of worker threads.\n *\n * @example\n * ```typescript\n * // run google searches and transform the result with an online api to produce a map of results\n * // but run maximum 4 api requests in parallel to speed things up\n * await pipe(\n * itr8FromArray([ 'Garfield', 'H\u00E4gar the Horrible', 'Droopy', 'Calvin and Hobbes', 'Fritz the Cat', 'Popeye' ])\n * parallel(\n * { concurrency: 4 },\n * map(async (term) => ...), // a call to google search to get the search results in html\n * map(async (html) => ...), // another api call that turns the html into structered json { name: 'Garfield', searchResults: [ ... ] }\n * ),\n * map(({name, searchResults}) => [name, searchResults]),\n * itr8ToObject, // like Object.fromEntries but for both synchronous and asynchronous iterators\n * )\n * // => {\n * // 'Garfield': [ ...urls ],\n * // 'H\u00E4gar the Horrible': [ ...urls ],\n * // 'Droopy': [ ...urls ],\n * // 'Calvin and Hobbes': [ ...urls ],\n * // 'Fritz the Cat': [ ...urls ],\n * // 'Popeye': [ ...urls ],\n * // }\n * ```\n *\n * @param options\n * @param transIt\n * @param {...(it:Iterator | AsyncIterator)=>Iterator | AsyncIterator} moreTransIts\n * @returns\n *\n * @category operators/async\n */\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E): E;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F): F;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G): G;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H): H;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H, fn9: (x: H) => I): I;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H, fn9: (x: H) => I, fn10: (x: I) => J): J;\n// function pipe(input: IN, fn1: (x: IN) => A, fn2: (x: A) => B, fn3: (x: B) => C, fn4: (x: C) => D, fn5: (x: D) => E, fn6: (x: E) => F, fn7: (x: F) => G, fn8: (x: G) => H, fn9: (x: H) => I, fn10: (x: I) => J, ...moreFns: Array<(x: unknown) => unknown>): unknown;\n// function parallel(\nfunction parallel(\n options: { concurrency: number; keepOrder?: boolean },\n transIt: TTransIteratorSyncOrAsync,\n ...moreTransIts: Array\n): TTransIteratorSyncOrAsync {\n // combine all parameters into a single transIterator in order to apply it\n const transItsCombined = moreTransIts.reduce(\n (acc, cur) => (input) => cur(acc(input)),\n transIt,\n );\n // = compose(transIt, ...moreTransIts)\n\n if (options.keepOrder === undefined || options.keepOrder) {\n return (\n inIt: Iterator | AsyncIterator,\n ): AsyncIterableIterator => {\n type TItOfItsElement = {\n callbackIt: TPushable & AsyncIterableIterator;\n subIt: TPushable & AsyncIterableIterator;\n };\n\n async function* iteratorOfIterables() {\n // create an iterator to push the results of each 'lane' to\n const outIteratorOfIterators = itr8Pushable();\n\n // first setup the (concurrent) forEach on the incoming iterator, so that things will be pushed to the pushable iterator\n (async () => {\n // const start = Date.now();\n // const timePassed = () => Date.now() - start;\n await pipe(\n inIt,\n forEach(\n async (inElement) => {\n // console.log(`${JSON.stringify(inElement)}: taking lane (${timePassed()} ms)`);\n const itOfItsElement: TItOfItsElement = {\n callbackIt: itr8Pushable(),\n subIt: itr8Pushable(),\n };\n outIteratorOfIterators.push(itOfItsElement);\n // actively drain the subIterator to force parallel processing\n // and push the results onto the subItPushable\n const subIt = transItsCombined(itr8FromSingleValue(inElement));\n // await forEach(itOfItsElement.subIt.push)(subIt);\n await forEach((v) => {\n // console.log(`${JSON.stringify(inElement)}: Pushing ${JSON.stringify(v)} to outIterator (${timePassed()} ms)`);\n itOfItsElement.subIt.push(v);\n })(subIt);\n // console.log(`${JSON.stringify(inElement)}: Pushing DONE to outIterator (${timePassed()} ms)`);\n itOfItsElement.subIt.done();\n // now wait until we get a signal that this subIterator has been processed (pulled in)\n // so this 'lane' can start processing a new record\n await itr8ToArray(itOfItsElement.callbackIt);\n // console.log(`${JSON.stringify(inElement)}: clearing lane because outIterator has processed all elemants... (${timePassed()} ms)`);\n },\n { concurrency: options.concurrency },\n ),\n );\n\n // after the forEach, make sure we indicate that the iterator is done!\n outIteratorOfIterators.done();\n })();\n\n // second we'll loop through the outIteratorOfIterators\n for await (const subItElement of outIteratorOfIterators) {\n yield* subItElement.subIt;\n // send signal back to forEach that the processing has finished for this subIterator\n subItElement.callbackIt.done();\n }\n }\n return iteratorOfIterables() as AsyncIterableIterator;\n };\n } else {\n return (\n inIt: Iterator | AsyncIterator,\n ): AsyncIterableIterator => {\n type TItElement =\n | { callbackIt: TPushable & AsyncIterableIterator }\n | { value: T };\n\n async function* iteratorOfValues() {\n // create an iterator to push calculated values onto\n const outIterator = itr8Pushable();\n\n // first setup the (concurrent) forEach on the incoming iterator, so that things will be pushed to the pushable iterator\n (async () => {\n await pipe(\n inIt,\n forEach(\n async (inElement) => {\n // actively drain the subIterator to force parallel processing\n // and push the results onto the pushable outIterator\n const subIt = transItsCombined(itr8FromSingleValue(inElement));\n await forEach((v) => outIterator.push({ value: v }))(subIt);\n // await forEach((v) => {\n // console.log(`${JSON.stringify(inElement)}: Pushing ${JSON.stringify(v)} to outIterator`);\n // outIterator.push({ value: v });\n // })(subIt);\n const callbackIt = itr8Pushable();\n // console.log(`${JSON.stringify(inElement)}: Pushing DONE to outIterator`);\n outIterator.push({ callbackIt });\n // now wait until we get a signal that this subIterator has been processed (pulled in)\n // so this 'lane' can start processing a new record\n await itr8ToArray(callbackIt);\n // console.log(`${JSON.stringify(inElement)}: clearing lane because outIterator has processed all elemants...`);\n },\n { concurrency: options.concurrency },\n ),\n );\n\n // after the forEach, make sure we indicate that the iterator is done!\n outIterator.done();\n })();\n\n // second we'll loop through the outIterator\n for await (const subItElement of outIterator) {\n if ((subItElement as any).callbackIt === undefined) {\n yield (subItElement as { value: T }).value;\n } else {\n // send signal back to forEach that the processing has finished for this subIterator\n (\n subItElement as {\n callbackIt: TPushable & AsyncIterableIterator;\n }\n ).callbackIt.done();\n }\n }\n }\n return iteratorOfValues() as AsyncIterableIterator;\n };\n }\n}\n\nexport { parallel };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Return true if every item returns true on the test function.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4, 5, 6 ]),\n * every((x) => x > 2), // => [ false ]\n * );\n * ```\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/boolean\n */\nconst every = (filterFn: (TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return { done: false, value: true, state: { done: true } };\n\n return thenable(filterFn(nextIn.value)).then((result) => {\n if (result) return { done: false, state: { done: false } };\n return { done: false, value: result, state: { done: true } };\n }).src;\n },\n () => ({ done: false }),\n );\n\nexport { every };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Return true if at least 1 item returns true on the test function.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4, 5, 6 ]),\n * some((x) => x > 2), // => [ true ]\n * );\n * ```\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/boolean\n */\nconst some = (filterFn: (TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return { done: false, value: false, state: { done: true } };\n\n return thenable(filterFn(nextIn.value)).then((result) => {\n if (result)\n return { done: false, value: result, state: { done: true } };\n return { done: false, state: { done: false } };\n }).src;\n },\n () => ({ done: false }),\n );\n\nexport { some };\n", "import { isPromise } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\nimport { TNextFnResult } from \"../../types.js\";\n\n/**\n * Translate each element into something else by applying the supplied mapping function\n * to each element.\n *\n * The mapping function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @param fn\n *\n * @category operators/general\n */\nconst map = (mapFn: (v: TIn) => TOut | Promise) => {\n const returnIteratorResultSync = (\n value: TOut,\n ): TNextFnResult => ({\n done: false,\n value,\n });\n const returnIteratorResultAsync = async (\n valuePromise: Promise,\n ): Promise> => ({\n done: false,\n value: await valuePromise,\n });\n let returnIteratorResult = (\n mapFnResult: TOut | Promise,\n ): TNextFnResult | Promise> => {\n if (isPromise(mapFnResult)) {\n returnIteratorResult = returnIteratorResultAsync;\n } else {\n returnIteratorResult = returnIteratorResultSync;\n }\n return returnIteratorResult(mapFnResult);\n };\n return powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n } else {\n return returnIteratorResult(mapFn(nextIn.value));\n // return thenable(mapFn(nextIn.value)).then((value) => ({\n // done: false,\n // value,\n // })).src; // return the 'raw' value or promise, not the 'wrapped' version\n\n // const nextValOrPromise = mapFn(nextIn.value);\n // if (isPromise(nextValOrPromise)) {\n // return (async () => {\n // return {\n // done: false,\n // value: await nextValOrPromise,\n // }\n // })();\n // } else {\n // return {\n // done: false,\n // value: nextValOrPromise,\n // }\n // }\n }\n },\n () => undefined,\n );\n};\n\nexport { map };\n", "import { pipe } from \"../../util/index.js\";\nimport {\n itr8FromIterable,\n itr8ToMultiIterable,\n} from \"../../interface/index.js\";\nimport { TTransIteratorSyncOrAsync } from \"../../types.js\";\nimport { map } from \"./map.js\";\nimport { isPromise } from \"../../util/index.js\";\n\n/**\n * This operator should make it easy to perform multiple calculations on the same input\n * operator, and returning a tuple containing the multiple outputs.\n * This can be useful for example if you need to add a timestamp, get the running average,\n * the running max, and the running total of the same data, and you only want to iterate\n * over the data once.\n *\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502input iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \u2502 \u2502 \u2502\n * \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2510\n * \u2502 transIt \u2502 \u2502 transIt \u2502 \u2502 transIt \u2502\n * \u2502 1 \u2502 \u2502 2 \u2502 ... \u2502 n \u2502\n * \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2518\n * \u2502 \u2502 | \u2502\n * \u2502 \u2502 | \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \n * \u2502\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502output iterator\u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * All arguments are the transIterators that need to be run (use compose(for more complex operations)).\n *\n * @example\n * ```typescript\n * await pipe(\n * itr8FromArray([ 1, 2, 3, 4 ])\n * branchAndMerge(\n * identity(), // keep the original values as the first element of the tuple\n * runningAverage(),\n * runningTotal(),\n * ),\n * map(([value, avg, total]) => ({ value, avg, total })),\n * itr8ToArray,\n * )\n * // => [\n * // { value: 1, avg: 1, total: 1 },\n * // { value: 2, avg: 1.5, total: 3 },\n * // { value: 3, avg: 2, total: 6 },\n * // { value: 4, avg: 2.5, total: 10 },\n * // ]\n * ```\n *\n * @param options\n * @param transIt\n * @param {...(it:Iterator | AsyncIterator)=>Iterator | AsyncIterator} moreTransIts\n * @returns\n *\n * @category operators/general\n */\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n transIt6: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n transIt6: TTransIteratorSyncOrAsync,\n transIt7: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt1: TTransIteratorSyncOrAsync,\n transIt2: TTransIteratorSyncOrAsync,\n transIt3: TTransIteratorSyncOrAsync,\n transIt4: TTransIteratorSyncOrAsync,\n transIt5: TTransIteratorSyncOrAsync,\n transIt6: TTransIteratorSyncOrAsync,\n transIt7: TTransIteratorSyncOrAsync,\n transIt8: TTransIteratorSyncOrAsync,\n): TTransIteratorSyncOrAsync;\nfunction branchAndMerge(\n transIt: TTransIteratorSyncOrAsync,\n ...moreTransIts: Array\n): TTransIteratorSyncOrAsync {\n return function (it) {\n const multiIterable = itr8ToMultiIterable(it);\n const itInput = itr8FromIterable(multiIterable);\n // const transIts = [transIt, ...moreTransIts];\n const moreTransItIterators = moreTransIts.map((transIt) =>\n pipe(itr8FromIterable(multiIterable), transIt),\n );\n\n let isAsync: boolean;\n const itOut = pipe(\n itInput,\n map((value) => {\n const itrResultsPossiblePromises = moreTransItIterators.map(\n (transItIterator) => transItIterator.next(),\n );\n if (isAsync === undefined) {\n isAsync = itrResultsPossiblePromises.some((result) =>\n isPromise(result),\n );\n }\n\n if (isAsync === false) {\n return [\n value,\n ...(\n itrResultsPossiblePromises as Array>\n ).map((result) => result.value),\n ];\n } else if (isAsync === true) {\n let otherValues: Array = [];\n return (async () => {\n for await (const result of itrResultsPossiblePromises) {\n otherValues.push(result.value);\n }\n return [value, ...otherValues];\n })();\n }\n }),\n );\n return itOut;\n };\n}\n\nexport { branchAndMerge };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Removes consecutive doubles.\n * If no argument is provided, standard !== will be used to compare both values.\n * If a mapping fn is provided, the result of the mapping fn will be compared using !==,\n * which means the mapping function should produce a 'simple' types like number or string.\n *\n * (The alternative option would have been to pass 2 arguments to the compare fn and if\n * it returns true, the elements would be considered equal)\n *\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ 1, 2, 2, 2, 3, 4, 4, 3 ]),\n * itr8.dedup(), // => [ 1, 2, 3, 4, 3 ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ { id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 4 }, { id: 3 } ])\n * itr8.dedup((a:{ id:number }) => id ) // => [ [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 3 } ];\n * );\n * ```\n *\n * @param mapFn\n *\n * @category operators/general\n */\nconst dedup = (mapFn?: (v: TIn) => any) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n\n // promise if mapFn is async!\n const valueToCompare = mapFn ? mapFn(nextIn.value) : nextIn.value;\n return thenable(valueToCompare).then((v) => {\n return v !== state\n ? { done: false, value: nextIn.value, state: v }\n : { done: false, state: v };\n }).src;\n },\n () => undefined,\n );\n\nexport { dedup };\n", "import { itr8FromIterable } from \"../../interface/index.js\";\nimport { TTransIteratorSyncOrAsync } from \"../../types.js\";\nimport { isPromise } from \"../../util/index.js\";\n\n/**\n * This operator should make it easy to distribute different categories on the input iterator,\n * to multiple child iterators for further processing per category.\n * The child iterator depends on the 'category' that is determined by the first element\n * of the tuple.\n *\n * Imagine things like: I need to calculate the averages 'per schoolyear'.\n * That would mean, categorize per schoolyear, and then calculate the average\n * of the inner iterators by using a map after distribute.\n *\n * If you are not going to use all output iterators, make sure to filter out\n * the categories you don't need before using distribute, because otherwise an unused\n * buffer will be held needlessly in memory.\n *\n * The category is compared using simple equality checks, so strings and numbers are an easy fit.\n * If you need more complex categories (like an array), make sure to return the same instance\n * as the category. (Maybe we should create a 'categorize' or 'groupBy' operator that\n * can help with dealing with more complex categories?)\n *\n * Questions:\n * - Imagine you use it to categorize http requests (for example by sender ip/port),\n * how do we 'close' a channel after a while so we can avoid the memory to keep growing?\n * I mean, after some time you'll assume that the same 'sender' has done, and the output terator's\n * next() call should return { done: true }. Would that be a setting,\n * like the (unfinished) 'abandoned timeout' in the 'multiIterable' operator?\n * - It could make sense to create a version that can handle multiple categories per value.\n * Like for instance: divisible by 2, divisible by 3, divisible by 5, etc.\n * where some values can be in multiple categories.\n * This could also be done by making a categorize operator that can produce multiple tuples\n * for each input, which would keep this operator simple.\n *\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502input iterator with tuples of the form [ category, value ] |\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 output iterator of iterators \u2502\n * \u2502 (1 next() for each category) \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 ...\n * \u2502 \u2502\n * \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250C\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 [ category 1, iterator ] \u2502 \u2502 [ category 2, iterator ] \u2502\n * \u2514\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * \u2502\n * \u2502\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u25BC\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 forEach([ cetegory, iterator ]) \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * |\n * \u21B3 pipe( iterator, )\n * ```\n *\n * @example\n * ```typescript\n * await pipe(\n * itr8ange(1, 1000),\n * map( (v) => [ v % 2 === 0 ? 'even' : 'odd', v ] as [string, number] ), // add the category to the value\n * // adding the category first allows us to easily filter out categories we don't need\n * distribute(),\n * map(([category, iterator]) => ({\n * category,\n * values: pipe(\n * iterator,\n * take(2),\n * toArray,\n * ),\n * })),\n * itr8ToArray,\n * )\n * // => [\n * // { category: 'odd', values: [ 1, 3 ] },\n * // { category: 'even', values: [ 2, 4 ] },\n * // ]\n * ```\n *\n * @category operators/general\n */\nfunction distribute(): TTransIteratorSyncOrAsync<\n [C, T],\n [C, IterableIterator | AsyncIterableIterator]\n> {\n const bufferMap = new Map>();\n // we need an ordered list in order to respond to next calls on the outer iterator\n const categoriesArray: Array = [];\n let categoriesIndex = -1;\n let distributionDone = false;\n\n const addToCategory = (category: C, value: T) => {\n if (bufferMap.has(category)) {\n bufferMap.get(category)!.push(value);\n } else {\n bufferMap.set(category, [value]);\n categoriesArray.push(category);\n }\n };\n\n /**\n * It will return the first value from the buffer of the given category,\n * and update the buffer at the same time.\n *\n * @param category\n * @returns the value from the buffer, or Symbol['categoryEmpty']\n */\n const getFromCategory = (category: C) => {\n if (bufferMap.has(category)) {\n const buffer = bufferMap.get(category);\n if (buffer && buffer.length > 0) {\n return buffer.shift();\n }\n }\n return Symbol[\"categoryEmpty\"];\n };\n\n /**\n * The function that will categorize the input iterator's values and update the internal state.\n * @param itResult\n */\n const distributeIn = (itResult: IteratorResult<[C, T]>) => {\n if (itResult.done) {\n distributionDone = true;\n } else {\n addToCategory(itResult.value[0], itResult.value[1]);\n }\n };\n\n return (inputIterator: Iterator<[C, T]> | AsyncIterator<[C, T]>) => {\n function* generateInnerIterableSync(category: C) {\n if (!bufferMap.has(category)) {\n throw new Error(`Category ${category} not found in bufferMap`);\n }\n\n let innerIterableDone = false;\n while (!innerIterableDone) {\n const valueToYieldMaybe = getFromCategory(category);\n if (valueToYieldMaybe !== Symbol[\"categoryEmpty\"]) {\n yield valueToYieldMaybe;\n } else if (distributionDone) {\n innerIterableDone = true;\n } else {\n distributeIn(inputIterator.next() as IteratorResult<[C, T]>);\n }\n }\n }\n\n /**\n * This function is a generator that will categorize the input iterator's values\n * and returns [category, iterator] tuples.\n */\n function* generateOuterIterableSync(\n firstNext: IteratorResult<[C, T]>,\n ): IterableIterator<[C, IterableIterator]> {\n for (\n let nextIn = firstNext;\n !nextIn.done;\n nextIn = inputIterator.next() as IteratorResult<[C, T]>\n ) {\n distributeIn(nextIn);\n\n while (categoriesIndex < categoriesArray.length - 1) {\n categoriesIndex += 1;\n const category = categoriesArray[categoriesIndex];\n yield [\n category,\n itr8FromIterable(generateInnerIterableSync(category)),\n ] as [C, IterableIterator];\n }\n }\n distributionDone = true;\n }\n\n async function* generateInnerIterableAsync(category: C) {\n if (!bufferMap.has(category)) {\n throw new Error(`Category ${category} not found in bufferMap`);\n }\n\n let innerIterableDone = false;\n while (!innerIterableDone) {\n const valueToYieldMaybe = getFromCategory(category);\n if (valueToYieldMaybe !== Symbol[\"categoryEmpty\"]) {\n yield valueToYieldMaybe;\n } else if (distributionDone) {\n innerIterableDone = true;\n } else {\n distributeIn((await inputIterator.next()) as IteratorResult<[C, T]>);\n }\n }\n }\n\n /**\n * This function is a generator that will categorize the input iterator's values\n * and returns [category, iterator] tuples.\n */\n async function* generateOuterIterableAsync(\n firstNext: Promise>,\n ): AsyncIterableIterator<[C, AsyncIterableIterator]> {\n for (\n let nextIn = await firstNext;\n !nextIn.done;\n nextIn = await inputIterator.next()\n ) {\n distributeIn(nextIn);\n\n while (categoriesIndex < categoriesArray.length - 1) {\n categoriesIndex += 1;\n const category = categoriesArray[categoriesIndex];\n yield [\n category,\n itr8FromIterable(generateInnerIterableAsync(category)),\n ] as [C, AsyncIterableIterator];\n }\n }\n distributionDone = true;\n }\n\n const firstNext = inputIterator.next();\n return isPromise(firstNext)\n ? generateOuterIterableAsync(firstNext)\n : generateOuterIterableSync(firstNext);\n };\n}\n\nexport { distribute };\n", "import { TNextFnResult } from \"../../types.js\";\nimport { isPromise } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Only keep elements where the filter function returns true.\n *\n * The filter function can be asynchronous (in which case the resulting iterator will be\n * asynchronous regardless of the input iterator)!\n *\n * @category operators/general\n */\nconst filter = (filterFn: (v: TIn) => boolean | Promise) => {\n // EXPERIMENTAL: create a self-replacing function (depending on sync or async)\n let generateNextFnResultFromFilterFnResult = function (\n firstFilterFnResult: boolean | Promise,\n nextIn,\n ): TNextFnResult | Promise> {\n const f = (filterFnResult, nextIn: IteratorResult) => {\n if (filterFnResult) {\n return { done: false, value: nextIn.value } as const;\n } else {\n return { done: false } as const;\n }\n };\n\n generateNextFnResultFromFilterFnResult = isPromise(firstFilterFnResult)\n ? (resultPromise, nextIn) =>\n (resultPromise as Promise).then((result) =>\n f(result, nextIn),\n )\n : f;\n return generateNextFnResultFromFilterFnResult(firstFilterFnResult, nextIn);\n };\n\n return powerMap(\n (nextIn, _state) => {\n if (nextIn.done) return { done: true };\n\n return generateNextFnResultFromFilterFnResult(\n filterFn(nextIn.value),\n nextIn,\n );\n\n // OLD: thenable is simple to use, but not performant\n // return thenable(filterFn(nextIn.value)).then((result) => {\n // if (result) return { done: false, value: nextIn.value };\n // return { done: false };\n // }).src;\n\n // const result = filterFn(nextIn.value);\n // if (isPromise(result)) {\n // return (async () => {\n // if (await result) return { done: false, value: nextIn.value };\n // return { done: false };\n // })();\n // } else {\n // if (result) return { done: false, value: nextIn.value };\n // return { done: false };\n // }\n },\n () => undefined,\n );\n};\n\nexport { filter };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * The incoming elements are arrays, and send out each element of the array 1 by one.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ [1, 2], [3, 4], [5, 6] ]),\n * flatten(), // => [ 1, 2, 3, 4, 5, 6 ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst flatten = () =>\n powerMap, TIn, void>(\n (nextIn, _state) => {\n if (nextIn.done) return { done: true };\n return { done: false, iterable: nextIn.value };\n },\n () => undefined,\n );\nexport { flatten };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Group the incoming elements so the output iterator will return arrays/tuples of a certain size.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4, 5, 6 ]),\n * groupPer(2), // => [ [1, 2], [3, 4], [5, 6] ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst groupPer = (groupSize: number) =>\n powerMap, { done: boolean; buffer: Array }>(\n (nextIn, state) => {\n if (state.done || (nextIn.done && state.buffer.length === 0)) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.buffer,\n state: { done: true, buffer: [] },\n };\n } else if (state.buffer.length + 1 === groupSize) {\n return {\n done: false,\n value: [...state.buffer, nextIn.value],\n state: { done: false, buffer: [] },\n };\n }\n return {\n done: false,\n state: { ...state, buffer: [...state.buffer, nextIn.value] },\n };\n },\n () => ({ done: false, buffer: [] }),\n );\n\nexport { groupPer };\n", "import { TTransIteratorSyncOrAsync } from \"../../types.js\";\n\n/**\n * This operator returns the same iterator, but makes sure it\n * will be an (Async)IterableIterator.\n *\n * @example\n * ```typescript\n * const iterableIterator = await pipe(\n * someBareIterator,\n * identity(),\n * )\n * ```\n *\n * @returns the same (Async)Iterator but guaranteed to be an (Async)IterableIterator\n *\n * @category operators/async\n */\nfunction identity(): TTransIteratorSyncOrAsync {\n return function (\n it: Iterator | AsyncIterator,\n ): IterableIterator | AsyncIterableIterator {\n if (it[Symbol.asyncIterator]) {\n return it as AsyncIterableIterator;\n } else if (it[Symbol.iterator]) {\n return it as IterableIterator;\n } else {\n const itOut: IterableIterator = {\n next: it.next as () => IteratorResult,\n [Symbol.iterator]: () => itOut,\n };\n return itOut;\n }\n };\n}\n\nexport { identity };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Intersperse the the argument bewteen each element of the iterator.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world', 'and', 'goodbye' ]),\n * intersperse('|'), // => [ [ 'hello', '|', 'world', '|', 'and', '|', 'goodbye' ] ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * intersperse(true), // => [ 1, true, 2, true, 3, true, 4 ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst intersperse = (intersperseThing: unknown) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n } else if (state) {\n return {\n done: false,\n iterable: [intersperseThing, nextIn.value],\n state,\n };\n }\n // first time, just return the first element\n return { done: false, iterable: [nextIn.value], state: true };\n },\n () => false,\n );\n\nexport { intersperse };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * To solve some problems you need to know what the next element(s) is (are) going\n * to be, or look back at the previous value(s).\n *\n * so instead of returning the simple value of the incoming iterator, an object will be returned\n * that looks like this:\n * ```typescript\n * {\n * value: 'the current value',\n * next: [ 'next value', 'next + 1 value' ],\n * previous: [ 'previous value', 'previous - 1 value' ],\n * }\n * ```\n *\n * @example\n * ```typescript\n * // the output of: find src \\( -type d -printf \"%p/\\n\" , ! -type d -print \\)\n * const str = `src/\n * src/interface/\n * src/interface/itr8ToArray.ts\n * src/interface/itr8Pushable.ts\n * src/interface/index.ts\n * src/peer/\n * src/peer/observable.ts\n * src/peer/parseJson.ts\n * src/types.ts\n * src/index.ts\n * src/operators/\n * src/operators/numeric/\n * src/operators/numeric/max.ts\n * src/operators/numeric/min.ts\n * src/operators/numeric/average.ts\n * src/operators/numeric/total.ts\n * src/operators/strings/\n * src/operators/strings/lineByLine.ts\n * src/operators/strings/stringToChar.ts\n * src/operators/general/\n * src/operators/general/uniq.ts\n * src/operators/general/reduce.ts\n * src/operators/general/split.ts\n * src/operators/boolean/\n * src/operators/boolean/every.ts\n * src/operators/boolean/some.ts\n * src/operators/index.ts`;\n *\n * const printableTreeView = pipe(\n * itr8FromString(str),\n * lineByLine(),\n * peek(),\n * // parse the string into a data structure (peeking to next to fill the isLastInLevel & isVeryLast flags)\n * map(({value, next, prev}) => {\n * const valueSplit = value.split('/');\n * const isDir = value.endsWith('/');\n * const pathLength = valueSplit.length - (isDir ? 2 : 1);\n * const nextIsDir = next[0]?.endsWith('/');\n * const nextPathLength = next[0]?.split('/').length - (nextIsDir ? 2 : 1);\n * const isLastInLevel = nextPathLength < pathLength;\n * const isVeryLast = next.length === 0;\n * return { isDir, name: valueSplit[pathLength], level: pathLength, isLastInLevel, isVeryLast };\n * }),\n * // turn the data structure into a new string\n * map(({ isDir, name, level, isLastInLevel, isVeryLast }) => {\n * const padding = pipe(\n * itr8FromSingleValue(' \u2502 ')\n * repeatEach(level - 1),\n * itr8ToString,\n * );\n *\n * const line = !(isLastInLevel || isVeryLast)\n * ? ' \u251C\u2500'\n * : ' \u2514\u2500' // (!isVeryLast ? ' \u2514\u2500' : '\u2500\u2534\u2500')\n * ;\n *\n * const filename = `${isDir ? '\uD83D\uDCC1' : '\uD83D\uDCC4'} ${name}`;\n *\n * return `${padding}${level > 0 ? line : ''}${filename}`;\n * }),\n * intersperse('\\n'),\n * itr8ToString,\n * )\n * // =>\n * // \uD83D\uDCC1 src\n * // \u251C\u2500\uD83D\uDCC1 interface\n * // \u2502 \u251C\u2500\uD83D\uDCC4 itr8ToArray.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC4 itr8Pushable.ts\n * // \u2502 \u2514\u2500\uD83D\uDCC4 index.ts\n * // \u251C\u2500\uD83D\uDCC1 peer\n * // \u2502 \u251C\u2500\uD83D\uDCC4 observable.ts\n * // \u2502 \u2514\u2500\uD83D\uDCC4 parseJson.ts\n * // \u251C\u2500\uD83D\uDCC4 types.ts\n * // \u251C\u2500\uD83D\uDCC4 index.ts\n * // \u251C\u2500\uD83D\uDCC1 operators\n * // \u2502 \u251C\u2500\uD83D\uDCC1 numeric\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 max.ts\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 min.ts\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 average.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 total.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC1 strings\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 lineByLine.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 stringToChar.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC1 general\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 uniq.ts\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 reduce.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 split.ts\n * // \u2502 \u251C\u2500\uD83D\uDCC1 boolean\n * // \u2502 \u2502 \u251C\u2500\uD83D\uDCC4 every.ts\n * // \u2502 \u2502 \u2514\u2500\uD83D\uDCC4 some.ts\n * // \u2502 \u2514\u2500\uD83D\uDCC4 index.ts\n * ```\n *\n * @category operators/general\n */\nconst peek = (peekForward = 1, peekBackward = 1) =>\n powerMap<\n TIn,\n { value: TIn; previous: TIn[]; next: TIn[] },\n { previous: TIn[]; current: TIn; next: TIn[] }\n >(\n (nextIn, state) => {\n if (nextIn.done) {\n // drain what's left of the next elements\n if (state.next.length === 0 || peekForward === 0) {\n return {\n done: true,\n state: {\n current: Symbol[\"ITR8_NO_CURRENT\"],\n next: [],\n previous: state.previous,\n },\n };\n } else {\n const [firstOfNext, ...restOfNext] = state.next;\n\n const newState = {\n current: firstOfNext,\n next: restOfNext || [],\n previous: [state.current, ...state.previous].slice(\n 0,\n peekBackward as number,\n ),\n };\n return {\n done: false,\n value: {\n value: newState.current,\n next: newState.next,\n previous: newState.previous,\n },\n state: newState,\n };\n }\n } else {\n // NOT nextIn.done\n if (state.next.length < peekForward) {\n const newState = {\n current: state.current, // still Symbol['ITR8_NO_CURRENT'] until we have enough next values\n next: [...state.next, nextIn.value].slice(0, peekForward as number),\n previous: state.previous,\n };\n return { done: false, state: newState };\n } else {\n // the 'normal' case in the middle of a flow\n const [firstOfNext, ...restOfNext] = state.next;\n const current = peekForward === 0 ? nextIn.value : firstOfNext;\n const newState = {\n current,\n next: [...(restOfNext || []), nextIn.value].slice(\n 0,\n peekForward as number,\n ),\n previous: (state.current === Symbol[\"ITR8_NO_CURRENT\"]\n ? state.previous\n : [state.current, ...(state.previous || [])]\n ).slice(0, peekBackward as number),\n };\n return {\n done: false,\n value: {\n value: newState.current,\n next: newState.next,\n previous: newState.previous,\n },\n state: newState,\n };\n }\n }\n },\n () => ({\n // hasPrevious: false,\n previous: [],\n current: Symbol[\"ITR8_NO_CURRENT\"],\n next: [],\n // hasNext\n }),\n );\n// const peek = (amountNext: number, amountPrevious: number = 0) => {\n\n// // return (it: Iterator | AsyncIterator):Iterator | AsyncIterator => {\n// // let inputs:Array> | IteratorResult> = [];\n// // let isAsyncInput:boolean;\n// // const addInputIfNeeded = async () => {\n// // if (inputs.length < amount) {\n// // if (isAsyncInput && inputs.length > 0) await inputs[0];\n// // const next = it.next();\n// // if (isPromise(next)) {\n// // // console.log(' add another (async) input, current nr of inputs = ', inputs.length, ' < ', amount);\n// // isAsyncInput = true;\n// // next.then((n) => {\n// // if (!n.done) {\n// // // console.log(' then: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n// // addInputIfNeeded();\n// // }\n// // });\n// // }\n// // inputs.push(next);\n// // }\n// // }\n\n// // const retVal = {\n// // [Symbol.asyncIterator]: () => retVal as AsyncIterableIterator,\n// // [Symbol.iterator]: () => retVal as IterableIterator,\n// // next: () => {\n// // // console.log(' next: call addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n// // addInputIfNeeded();\n// // if (inputs.length > 0) {\n// // const [firstInput, ...remainingInputs] = inputs;\n// // inputs = remainingInputs;\n// // // console.log(' next: call 2 to addInputIfNeeded(), current nr of inputs = ', inputs.length, ' < ', amount);\n// // addInputIfNeeded();\n// // // console.log(' next: return ', firstInput);\n// // return firstInput;\n// // }\n// // return isAsyncInput\n// // ? Promise.resolve({ done: true, value: undefined }) as Promise>\n// // : { done: true, value: undefined } as IteratorResult;\n// // }\n// // };\n\n// // return retVal as any;\n// // }\n// };\n\nexport { peek };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * The reduce() method executes a user-supplied \"reducer\" callback function on each element of\n * the iterator, in order, passing in the return value from the calculation on the preceding\n * element. The final result of running the reducer across all elements of the array is a\n * single value, so the ouput iterator will only produce 1 result before finishing.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * reduce((acc, cur) => acc + cur, 0),\n * );\n * // => [ 10 ]\n * ```\n *\n * The reduce function can be an asynchronous function (in which case the resulting\n * iterator will be asynchronous regardless of the input iterator)!\n *\n * @param reducer\n * @param initialValue: value passed as 'accumulator' on the very first call to the reducer function\n *\n * @category operators/general\n */\nconst reduce = (\n reducer: (\n accumulator: TOut,\n currentValue: TIn,\n presentIndex?: number,\n ) => TOut | Promise,\n initialValue: TOut,\n) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n }\n\n const acc = state.accumulator;\n\n if (nextIn.done) {\n return { done: false, value: acc, state: { ...state, done: true } };\n }\n\n return thenable(reducer(acc, nextIn.value, state.index)).then(\n (reduced) => ({\n done: false,\n state: {\n ...state,\n index: state.index + 1,\n accumulator: reduced,\n },\n }),\n ).src;\n\n // const reduced = params.reducer(acc, nextIn.value, state.index);\n // if (isPromise(reduced)) {\n // return (async () => ({\n // done: false,\n // state: {\n // ...state,\n // index: state.index + 1,\n // accumulator: await reduced,\n // }\n // }))();\n // }\n\n // // synchronous\n // return {\n // done: false,\n // state: {\n // ...state,\n // index: state.index + 1,\n // accumulator: reduced,\n // }\n // };\n },\n () => ({ index: 0, accumulator: initialValue, done: false }),\n );\n\nexport { reduce };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Repeat the entire iterator the given amount.\n * If the amount is zero (or negative), you'll end up with an empty iterator.\n *\n * BEWARE: In order to be able to repeat everything, the entire collection must be kept in memory\n * (as opposed to repeatEach where only a single element needs to be stored).\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world' ]),\n * repeat(2)\n * ) // => [ 'hello', 'world', 'hello', 'world' ]\n * ```\n * @example\n * ```typescript\n * // creating an indentation function is easy (even if it's 0)\n * function getIndentation(indentationLevel, tabSize = 2) {\n * const singleTab = pipe(\n * itr8FromSingleValue(' '),\n * repeat(tabSize),\n * itr8ToSTring,\n * );\n * return pipe(\n * itr8FromSingleValue(singleTab)\n * repeat(indentationLevel),\n * itr8ToSTring,\n * );\n * }\n * getIndentation(3); // => ' ' (6 spaces)\n * ```\n *\n * @category operators/general\n */\nconst repeat = (count = 2) =>\n powerMap; remaining: number }>(\n (nextIn, { list, remaining }) => {\n if (remaining <= 0) {\n return { done: true };\n }\n\n if (nextIn.done) {\n return {\n done: false,\n iterable: list,\n state: { list, remaining: remaining - 1 },\n };\n }\n\n return {\n done: false,\n value: nextIn.value,\n state: { list: list.concat(nextIn.value), remaining },\n };\n },\n () => ({ list: [], remaining: count - 1 }),\n );\n\nexport { repeat };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Repeat each element of the iterator for the given amount.\n * If the amount is zero (or negative), you'll end up with an empty iterator.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world' ]),\n * repeatEach(2)\n * ) // => [ 'hello', 'hello', 'world', 'world' ]\n * ```\n * @example\n * ```typescript\n * // creating an indentation function is easy (even if it's 0)\n * function getIndentation(indentationLevel, tabSize = 2) {\n * const singleTab = pipe(\n * itr8FromSingleValue(' '),\n * repeatEach(tabSize),\n * itr8ToSTring,\n * );\n * return pipe(\n * itr8FromSingleValue(singleTab)\n * repeatEach(indentationLevel),\n * itr8ToSTring,\n * );\n * }\n * getIndentation(3); // => ' ' (6 spaces)\n * ```\n *\n * @category operators/general\n */\nconst repeatEach = (count = 2) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n }\n return {\n done: false,\n iterable: (function* () {\n for (let i = 0; i < count; i++) {\n yield nextIn.value;\n }\n })(),\n };\n },\n () => undefined,\n );\n\nexport { repeatEach };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * The runnigReduce() method executes a user-supplied \"reducer\" callback function on each element of\n * the iterator, in order, passing in the return value from the calculation on the preceding\n * element. Eaxch next call produces the result of running the reducer across all elements so far.\n * (called scan in RxJS)\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * reduce((acc, cur) => acc + cur, 0),\n * );\n * // => [ 1, 3, 6, 10 ]\n * ```\n *\n * The reduce function can be an asynchronous function (in which case the resulting\n * iterator will be asynchronous regardless of the input iterator)!\n *\n * @param reducer\n * @param initialValue: value passed as 'accumulator' on the very first call to the reducer function\n *\n * @category operators/general\n */\nconst runningReduce = (\n reducer: (\n accumulator: TOut,\n currentValue: TIn,\n presentIndex?: number,\n ) => TOut | Promise,\n initialValue: TOut,\n) =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n }\n\n const acc = state.index === 0 ? initialValue : state.accumulator;\n\n if (nextIn.done) {\n return { done: true, value: acc, state };\n }\n\n return thenable(reducer(acc, nextIn.value, state.index)).then(\n (reduced) => ({\n done: false,\n value: reduced,\n state: {\n ...state,\n index: state.index + 1,\n accumulator: reduced,\n },\n }),\n ).src;\n },\n () => ({ index: 0, accumulator: initialValue }),\n );\n\nexport { runningReduce };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Skip the 'amount' first elements and return all the others unchanged.\n *\n * @param amount\n *\n * @category operators/general\n */\nconst skip = (params = 0) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n if (state < params) return { done: false, state: state + 1 };\n return { done: false, value: nextIn.value };\n },\n () => 0,\n );\n\nexport { skip };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * Skip the first elements as long as the filter function returns true,\n * and return all the others unchanged.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([1, 2, 3, 4, 1, 2, 6]),\n * skipWhile(x => x < 4), // => [4, 1, 2, 6]\n * );\n * ```\n *\n * @param whileFn a fuction that returns true as long as elements should be dropped\n *\n * @category operators/general\n */\nconst skipWhile = (whileFn: (v: TIn) => boolean | Promise) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n if (state) {\n return thenable(whileFn(nextIn.value)).then(\n (keepSkipping: boolean, _isSync: boolean) =>\n keepSkipping\n ? { done: false, state }\n : { done: false, value: nextIn.value, state: false },\n ).src;\n // return { done: false, state };\n }\n return { done: false, value: nextIn.value, state: false };\n },\n () => true,\n );\n\nexport { skipWhile };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Sorts the elements (using the given sort function if provided).\n * Beware: all elements need to fit in memory before they can be sorted!\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, -2, 7, 4 ]),\n * sort(), // => [ -2, 1, 4, 7 ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ { v: 1 }, { v: -4 }, { v: 7 }, { v: 2 } ]),\n * itr8.sort((a:{ v:number }, b:{ v:number }, => a.v - b.v))\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/general\n */\nconst sort = (sortFn?: (a: TIn, b: TIn) => number) =>\n powerMap(\n (nextIn: IteratorResult, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n // sort function modifes the state, so this is not 'pure'\n return {\n done: false,\n iterable: state.list.sort(sortFn ? sortFn : undefined),\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, list: [...state.list, nextIn.value] },\n };\n // bad (but more performant?): modifying state.list instead of returning a new state!\n // state.list.push(nextIn.value);\n // return { done: false, state: { ...state, list: state.list /* [...state.list, nextIn.value] */ } };\n },\n () => ({ done: false, list: [] }),\n );\n\nexport { sort };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * like string.split => output arrays of elements and use the given parameter as a delimiter\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', '|', 'world' ]),\n * split('|'), // => [ ['hello'], ['world'] ]\n * );\n * ```\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, true, 2, 3, true, 4 ]),\n * split(true), // => [ [1], [2,3], [4] ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst split = (delimiter) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n if (state === null) {\n return { done: true };\n }\n return { done: false, value: state, state: null };\n } else if (nextIn.value === delimiter) {\n return { done: false, value: state || [], state: [] };\n }\n return {\n done: false,\n state: [...(state === null ? [] : state), nextIn.value],\n };\n },\n () => null,\n );\n\nexport { split };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Only take 'amount' elements and then stop.\n *\n * (Beware: if the source is an Observable or a stream, it will not know that we stopped,\n * so the buffer will keep building up. The observable or stream should be closed by the user!)\n *\n * @param amount\n *\n * @category operators/general\n */\nconst take = (count = Infinity) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n if (state < count) {\n const newState = state + 1;\n return {\n done: false,\n value: nextIn.value,\n state: newState,\n isLast: newState == count,\n };\n }\n return { done: true };\n },\n () => 0,\n );\n\nexport { take };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Tap will run a function 'on the side' without while passing the iterator\n * unchanged to the next.\n *\n * @param fn\n *\n * @category operators/general\n */\nconst tap = (tapFn: (value: TIn) => void) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n } else {\n try {\n tapFn(nextIn.value);\n } catch (e) {\n console.warn(\"Tap function caused an exception\", e, e.stack);\n }\n return { done: false, value: nextIn.value };\n }\n },\n () => undefined,\n );\n\nexport { tap };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Only returns unique elements. It works with a simple compare, so ok for simple types like\n * numbers and strings, but for objects it will work on the reference. If you need something\n * more sophisticated, ```uniqBy(...)``` is propably what you need.\n *\n * Beware: all unique elements need to fit in memory to keep track of the ones that we already\n * have seen!\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, -2, 7, 4, -2, -2, 4, 1 ]),\n * uniq(), // => [ 1, -2, 7, 4 ]\n * );\n * ```\n *\n * @category operators/general\n */\nconst uniq = () =>\n powerMap>(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n } else if (state.has(nextIn.value)) {\n return { done: false, state };\n }\n const newState = new Set(state);\n newState.add(nextIn.value);\n return { done: false, value: nextIn.value, state: newState };\n },\n () => new Set([]),\n );\n\nexport { uniq };\n", "import { powerMap } from \"./powerMap.js\";\n\n/**\n * Only returns unique elements by comparing the result of the mapping function applied\n * to the element.\n * Beware: all mapped elements need to fit in memory to keep track of the ones that we already\n * have seen!\n *\n * @example\n * ```typescript\n * pipe(\n * itr8.itr8FromArrayAsync([ { id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 4 }, { id: 3 } ])\n * itr8.uniqBy((a:{ id:number }) => id ) // => [ [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ];\n * );\n * ```\n *\n * @param mapFn\n *\n * @category operators/general\n */\nconst uniqBy = (mapFn: (v: TIn) => TMapFn) =>\n powerMap>(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n const hash = mapFn(nextIn.value);\n if (state.has(hash)) {\n return { done: false, state };\n }\n const newState = new Set(state);\n newState.add(hash);\n return { done: false, value: nextIn.value, state: newState };\n },\n () => new Set([]),\n );\n\nexport { uniqBy };\n", "import { thenable } from \"../../util/index.js\";\nimport { powerMap } from \"./powerMap.js\";\n\n/**\n * The zip() operator outputs tuples containing 1 element from the first and\n * one element from the second iterator. The first iterator is leading, so when\n * the first iterator is done, the output iterator is done. When the second iterator\n * is 'shorter', the tuples will contain undefined as the second element.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * zip(itr8FromArray([ 'a', 'b', 'c', 'd' ]), // => [ [1, 'a'], [2, 'b'], [3, 'c'], [4, 'd' ] ]\n * );\n * ```\n *\n * @param secondIterator\n *\n * @category operators/general\n */\nconst zip = (secondIterator: Iterator | AsyncIterator) =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n }\n\n return thenable(secondIterator.next()).then((secondNext) => ({\n done: false,\n value: [nextIn.value, (secondNext as IteratorResult).value],\n })).src;\n\n // const secondNext = secondIterator.next();\n // if (isPromise(secondNext)) {\n // return (async () => ({\n // done: false,\n // value: [nextIn.value, (await secondNext as IteratorResult).value],\n // }))();\n // }\n\n // // synchronous\n // return {\n // done: false,\n // value: [nextIn.value, (secondNext as IteratorResult).value],\n // };\n },\n () => undefined,\n );\n\nexport { zip };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output the average.\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,100),\n * average(), // => [ 50 ]\n * );\n * ```\n *\n * @param it\n * @param amount\n *\n * @category operators/numeric\n */\nconst average = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return {\n done: false,\n value: state.sum / state.count,\n state: { ...state, done: true },\n };\n const newCount = state.count + 1;\n const newSum = state.sum + nextIn.value;\n return { done: false, state: { ...state, count: newCount, sum: newSum } };\n },\n () => ({ done: false, count: 0, sum: 0 }),\n );\n\nexport { average };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output a single thing which is the highest of all values.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 7, 4 ]),\n * total(), // => [ 7 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst max = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.max,\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, max: Math.max(state.max, nextIn.value) },\n };\n },\n () => ({ done: false, max: -Infinity }),\n );\n\nexport { max };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output a single thing which is the lowest of all values.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, -2, 7, 4 ]),\n * total(), // => [ -2 ]\n * );\n * ```\n * @param amount\n *\n * @category operators/numeric\n */\nconst min = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.min,\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, min: Math.min(state.min, nextIn.value) },\n };\n },\n () => ({ done: false, min: Infinity }),\n );\n\nexport { min };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output the percentile(x)\n * It is simply using the nearest-rank method,\n * cfr. [Wikipedia](https://en.wikipedia.org/wiki/Percentile#Calculation_methods)\n * but it will only keep an ordered list of the n largest elements so far, which means that\n * computing the 90th percentile only needs to keep 10% of all the values seen in memory,\n * but the 50th percentile needs a buffer of 50% of all values.\n *\n * Various 'streaming' implementations exist, but they are more complex, so ... maybe later.\n *\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,100),\n * percentile(95), // => [ 95 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst percentile = (percentage: number) =>\n powerMap<\n number,\n number,\n { done: boolean; count: number; topArray: number[] }\n >(\n (nextIn, state) => {\n if (state.done) return { done: true };\n if (nextIn.done)\n return {\n done: false,\n value: state.topArray[0],\n state: { ...state, done: true },\n };\n const newCount = state.count + 1;\n const newTopArraySize =\n Math.floor(((100 - percentage) / 100) * newCount) + 1;\n const newTopArray = [...state.topArray, nextIn.value];\n newTopArray.sort((a, b) => a - b);\n while (newTopArraySize < newTopArray.length) {\n newTopArray.shift();\n }\n // console.log('value', nextIn.value, 'percentage', percentage, 'count', state.count, 'newTopArraySize', newTopArraySize, 'state.topArray', state.topArray);\n return {\n done: false,\n state: { ...state, count: newCount, topArray: newTopArray },\n };\n },\n () => ({ done: false, count: 0, topArray: [] }),\n );\n\nexport { percentile };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * On every item, output the average so far\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,10),\n * runningAverage(), // => [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]\n * );\n * ```\n *\n * @param it\n * @param amount\n *\n * @category operators/numeric\n */\nconst runningAverage = () =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n const newCount = state.count + 1;\n const newSum = state.sum + nextIn.value;\n return {\n done: false,\n state: { ...state, count: newCount, sum: newSum },\n value: newSum / newCount,\n };\n },\n () => ({ done: false, count: 0, sum: 0 }),\n );\n\nexport { runningAverage };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * On every item, output the percentile(x) so far\n * @example\n * ```typescript\n * pipe(\n * itr8Range(1,10),\n * percentile(50), // => [ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst runningPercentile = (percentage: number) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n const newCount = state.count + 1;\n const newTopArraySize =\n Math.floor(((100 - percentage) / 100) * newCount) + 1;\n const newTopArray = [...state.topArray, nextIn.value];\n newTopArray.sort((a, b) => a - b);\n while (newTopArraySize < newTopArray.length) {\n newTopArray.shift();\n }\n // console.log('value', nextIn.value, 'percentage', percentage, 'count', state.count, 'newTopArraySize', newTopArraySize, 'state.topArray', state.topArray);\n return {\n done: false,\n state: { ...state, count: newCount, topArray: newTopArray },\n value: newTopArray[0],\n };\n },\n () => ({ count: 0, topArray: [] }),\n );\n\nexport { runningPercentile };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * On every item, output the total so far.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * runningTotal(), // => [ 1, 3, 6, 10 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst runningTotal = () =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n const newTotal = state + nextIn.value;\n return { done: false, value: newTotal, state: newTotal };\n },\n () => 0,\n );\n\nexport { runningTotal };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Output a single thing containing the sum of all values.\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 1, 2, 3, 4 ]),\n * total(), // => [ 10 ]\n * );\n * ```\n *\n * @param amount\n *\n * @category operators/numeric\n */\nconst total = () =>\n powerMap(\n (nextIn, state) => {\n if (state.done) {\n return { done: true };\n } else if (nextIn.done) {\n return {\n done: false,\n value: state.total,\n state: { ...state, done: true },\n };\n }\n return {\n done: false,\n state: { ...state, total: state.total + nextIn.value },\n };\n },\n () => ({ done: false, total: 0 }),\n );\n\nexport { total };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * The input must be a stream of characters or strings,\n * and the output will be 1 string for each line.\n * \\n is used as the default line separator, but you can pass any string as a parameter\n * to be used as the line separator!\n *\n * @example\n * ```typescript\n * // simplest case: an iterator of single characters\n * pipe(\n * itr8FromArray([ 'h', 'e', 'l', 'l', 'o', '\\n', 'w', 'o', 'r', 'l', 'd' ]),\n * lineByLine(), // => [ 'hello', 'world' ]\n * );\n *\n * // second case: an iterator of string chunks\n * pipe(\n * itr8FromArray(['Hel', 'lo\\nWorld\\n\\nGo', 'od', 'by', 'e', '\\nSpace', '!']),\n * lineByLine(), // => ['Hello', 'World', '', 'Goodbye', 'Space!'];\n * );\n *\n * // thrid case: the newline separator is something else than \\n\n * pipe(\n * itr8FromArray(['Hel', 'lo
>World

Go', 'od', 'by', 'e', '
Space', '!']),\n * lineByLine(), // => ['Hello', 'World', '', 'Goodbye', 'Space!'];\n * );\n * ```\n * @param {string} separator: the string that will be considered the newline sequence\n * @category operators/strings\n */\nconst lineByLine = (splitBy = \"\\n\") =>\n powerMap(\n (nextIn, { done, buffer }) => {\n if (nextIn.done) {\n if (done) {\n return { done: true, state: { done: true, buffer: \"\" } };\n } else {\n return {\n done: false,\n value: buffer,\n state: { done: true, buffer: \"\" },\n };\n }\n } else {\n const lines = nextIn.value.split(splitBy as string);\n if (lines.length === 1) {\n return {\n done: false,\n state: { done: false, buffer: buffer + lines[0] },\n };\n } else if (lines.length === 2) {\n return {\n done: false,\n value: buffer + lines[0],\n state: { done: false, buffer: lines[1] },\n };\n } else {\n return {\n done: false,\n iterable: [buffer + lines[0], ...lines.slice(1, -1)],\n state: { done: false, buffer: lines[lines.length - 1] },\n };\n }\n }\n },\n () => ({ done: false, buffer: \"\" }),\n );\n\n// Original implementation by combining other operators\n// const lineByLine = () => compose(\n// stringToChar(),\n// split('\\n'),\n// map(x => x.reduce((acc, cur) => acc + cur, '')),\n// );\n\nexport { lineByLine };\n", "import { itr8FromString } from \"../../interface/itr8FromString.js\";\nimport { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Takes all strings from the input and outputs them as single characters\n * @example\n * ```typescript\n * pipe(\n * itr8FromArray([ 'hello', 'world' ]),\n * stringToChar(), // => [ 'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd' ]\n * );\n * ```\n *\n * @category operators/strings\n */\nconst stringToChar = () =>\n powerMap(\n (nextIn, _state) => {\n if (nextIn.done) {\n return { done: true };\n }\n return {\n done: false,\n iterable: itr8FromString(nextIn.value),\n };\n },\n () => undefined,\n );\n\nexport { stringToChar };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Mainly useful on async iterators (for example generated from a stream of events), but see below for other options.\n *\n * Wait for x milliseconds of 'no events' before firing one.\n * So an event will either not be handled (busy period),\n * or handled after the calm period (so with a delay of x milliseconds)\n *\n * The second parameter can be used if the timestamps can be calculated from the values on the input iterator\n * (by default Date.now() will be used).\n * This makes it possible to use this operator on synchronous iterators as well!\n *\n * @example\n * ```typescript\n * // imagine a stream of values fired at this pace onto an asyncIterator called itIn:\n * // 1, wait 10ms, 2, 3, wait 30ms, 4, wait 10ms, 5, wait 10ms, 6, 7, 8, 9, wait 40ms, 10\n * const result = await pipe(itIn, debounce(20), itr8ToArray);\n * // => [1, 4, 10]\n *\n * const valuesWithTimestamps = [\n * { value: 1, timestamp: 0 },\n * { value: 2, timestamp: 10 },\n * { value: 3, timestamp: 10 },\n * { value: 4, timestamp: 40 },\n * { value: 5, timestamp: 50 },\n * { value: 6, timestamp: 60 },\n * { value: 7, timestamp: 60 },\n * { value: 8, timestamp: 60 },\n * { value: 9, timestamp: 60 },\n * { value: 10, timestamp: 100 },\n * ];\n *\n * // or get the timestamp from the input values\n * const result = await pipe(\n * itr8FromIterable(valuesWithTimestamps),\n * debounce(20, ([_v, ts]) => ts), // debounce with function that gets timestamp from input\n * map(([v, _ts]) => v), // only keep values\n * itr8ToArray,\n * );\n * // => [1, 4, 10]\n * ```\n *\n * @category operators/timeBased\n */\nconst debounce = (\n cooldownMilliseconds: number,\n getTimestamp = (_value: TIn) => Date.now(),\n) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) return { done: true };\n const newState = getTimestamp(nextIn.value);\n const timePassed = newState - state;\n if (timePassed > cooldownMilliseconds) {\n return { done: false, value: nextIn.value, state: newState };\n }\n return { done: false, state: newState };\n },\n () => -Infinity,\n );\n\nexport { debounce };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Simply delay every element by the given nr of milliseconds.\n * (Will always produce an async iterator!).\n *\n * @category operators/timeBased\n */\nconst delay = (timeout: number) =>\n powerMap(\n (nextIn, _state) => {\n return new Promise((resolve /*, reject*/) => {\n setTimeout(() => resolve(nextIn), timeout);\n });\n },\n () => undefined,\n );\n\nexport { delay };\n", "import { powerMap } from \"../general/powerMap.js\";\n\n/**\n * Mainly useful on async iterators (for example generated from a stream of events), but see below for other options.\n *\n * Only throw events at most every x milliseconds.\n *\n * So when a few events happen quickly in succession, only the first one will be handled,\n * and the next ones will be ignored until enough time (x ms) has passed with\n * the previously handled event.\n *\n * The second parameter can be used if the timestamps can be calculated from the values on the input iterator\n * (by default Date.now() will be used).\n * This makes it possible to use this operator on synchronous iterators as well!\n *\n * @example\n * ```typescript\n * // imagine a stream of values fired at this pace onto an asyncIterator called itIn:\n * // 1, wait 5ms, 2, 3, wait 15ms, 4, wait 5ms, 5, wait 5ms, 6wait 10ms, 7wait 5ms, 8\n\n * const result = await pipe(itIn, throttle(15), itr8ToArray);\n * // => [1, 4, 7]\n *\n * const valuesWithTimestamps = [\n * { value: 1, timestamp: 0 },\n * { value: 2, timestamp: 5 },\n * { value: 3, timestamp: 5 },\n * { value: 4, timestamp: 20 },\n * { value: 5, timestamp: 25 },\n * { value: 6, timestamp: 30 },\n * { value: 7, timestamp: 40 },\n * { value: 8, timestamp: 45 },\n * ];\n *\n * // or get the timestamp from the input values\n * const result = await pipe(\n * itr8FromIterable(valuesWithTimestamps),\n * throttle(15, ([_v, ts]) => ts), // throttle with function that gets timestamp from input\n * map(([v, _ts]) => v), // only keep values\n * itr8ToArray,\n * );\n * // => [1, 4, 7]\n * ```\n * @category operators/timeBased\n */\nconst throttle = (\n throttleMilliseconds: number,\n getTimestamp = (_value: TIn) => Date.now(),\n) =>\n powerMap(\n (nextIn, state) => {\n if (nextIn.done) {\n return { done: true };\n }\n const now = getTimestamp(nextIn.value);\n\n if (now - state > throttleMilliseconds) {\n return { done: false, value: nextIn.value, state: now };\n }\n return { done: false, state };\n },\n () => -Infinity,\n );\n\nexport { throttle };\n"], + "mappings": "AAsBA,IAAMA,EAAY,SAAmBC,EAAmC,CACtE,OAEEA,GAAM,MACN,OAAO,UAAU,SAAS,KAAKA,CAAC,IAAM,kBAE1C,EAqBMC,EAAgB,OAAO,eAAe,gBAAkB,CAE9D,CAAC,EAAE,YAiDGC,EAAeC,GAAuB,CAC1C,GAAIJ,EAAUI,CAAC,EAAG,CAEhB,IAAMC,EAAO,CACX,IAAKD,EACL,KAAM,IAAIE,IAASH,EAASC,EAAE,KAAK,GAAG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,KAAM,GAAO,MAAAD,CAAM,CAC9B,EACA,IAAM,IACR", + "names": ["isPromise", "p", "AsyncFunction", "thenable", "x", "newX", "args", "value", "okHandler", "retVal", "thenableFactory", "y", "cachedThenable", "firstRun", "thenResult", "okHandlerResult", "doAfter", "f", "valueOrPromise", "doAfterFactory", "doAfterObj", "forLoop", "initialStateFactory", "testBeforeEach", "afterEach", "codeToExecute", "initialState", "isSyncInit", "testResult", "isSyncTest", "_", "isSyncBody", "firstStateAfterEach", "isSyncAfterBody", "state", "compose", "first", "params", "acc", "cur", "arg", "pipe", "input", "fn1", "functionsToApply", "forEach", "handler", "options", "it", "throwCount", "maxRunningHandlers", "runningHandlers", "waitForOpenSpot", "addToRunningHandlersList", "handlerPromise", "tryHandler", "v", "errorCatcher", "e", "handlerPossiblePromise", "isPromise", "nextPromiseOrValue", "nextPromise", "handleNext", "nextValue", "next", "handlerPossiblePromiseIn", "itr8FromArray", "a", "itr8FromArrayAsync", "a", "x", "itr8FromImpureFunction", "f", "retVal", "thenable", "value", "itr8FromIterable", "it", "itr8FromSingleValue", "v", "itr8FromSingleValueAsync", "v", "itr8FromString", "s", "itr8FromIterable", "itr8FromStringAsync", "s", "x", "itr8Pushable", "bufferSize", "buffer", "currentResolve", "currentDataPromise", "createNewCurrentDataPromise", "resolve", "retVal", "value", "itr8Interval", "intervalMilliseconds", "it", "itr8Pushable", "interval", "origDone", "itr8Range", "from", "to", "step", "stepValue", "upwards", "i", "itr8RangeAsync", "from", "to", "step", "stepValue", "upwards", "i", "itr8ToArray", "iterator", "n", "isPromise", "asyncResult", "result", "nSync", "itr8ToObject", "iterator", "n", "isPromise", "asyncResult", "k", "v", "result", "nSync", "itr8ToString", "iterator", "n", "isPromise", "asyncResult", "result", "nSync", "powerMapWithoutDoAfter", "nextFn", "initialStateFactory", "operatorFunction", "itIn", "pState", "operatorState", "generateFirstReturnValIfPossible", "pipe", "doAfter", "nextIn", "curNextFnResult", "returnedIterator", "generateDoneSync", "itr8FromIterable", "currentOutputIteratorNext", "generateNextFromOutputIteratorSync", "possibleNext", "generateNextReturnValSync", "outputIteratorIsAsync", "inputIteratorIsAsync", "nextFnIsAsync", "generateDoneAsync", "generateNextFromOutputIteratorAsync", "possibleNextValueOrPromise", "isPromise", "generateNextReturnValAsync", "nextInPromiseOrValue", "curNextFnResultPromiseOrValue", "n", "nResolved", "value", "err", "transIt", "input", "iterator", "iterable", "f", "forLoop", "thenable", "_forLoopResult", "newState", "retVal", "takeWhile", "filterFn", "powerMapWithoutDoAfter", "nextIn", "_state", "thenable", "filterFnResult", "itr8ToMultiIterable", "it", "subscriberMap", "buffer", "cleanBuffer", "minIndex", "pipe", "takeWhile", "i", "forEach", "iteratorGetter", "outIt", "index", "value", "error", "mostRecent", "initalValue", "it", "nextOut", "resolveNextOutRead", "handleInputPromise", "nextOutRead", "isPromise", "resolve", "reject", "retVal", "value", "err", "prefetch", "amount", "it", "inputs", "isAsyncInput", "addInputIfNeeded", "next", "isPromise", "n", "retVal", "firstInput", "remainingInputs", "value", "err", "parallel", "options", "transIt", "moreTransIts", "transItsCombined", "acc", "cur", "input", "inIt", "iteratorOfIterables", "outIteratorOfIterators", "itr8Pushable", "pipe", "forEach", "inElement", "itOfItsElement", "subIt", "itr8FromSingleValue", "v", "itr8ToArray", "subItElement", "iteratorOfValues", "outIterator", "callbackIt", "every", "filterFn", "powerMapWithoutDoAfter", "nextIn", "state", "thenable", "result", "some", "filterFn", "powerMapWithoutDoAfter", "nextIn", "state", "thenable", "result", "map", "mapFn", "returnIteratorResultSync", "value", "returnIteratorResultAsync", "valuePromise", "returnIteratorResult", "mapFnResult", "isPromise", "powerMapWithoutDoAfter", "nextIn", "_state", "branchAndMerge", "transIt", "moreTransIts", "it", "multiIterable", "itr8ToMultiIterable", "itInput", "itr8FromIterable", "moreTransItIterators", "pipe", "isAsync", "map", "value", "itrResultsPossiblePromises", "transItIterator", "result", "isPromise", "otherValues", "dedup", "mapFn", "powerMapWithoutDoAfter", "nextIn", "state", "valueToCompare", "thenable", "v", "distribute", "bufferMap", "categoriesArray", "categoriesIndex", "distributionDone", "addToCategory", "category", "value", "getFromCategory", "buffer", "distributeIn", "itResult", "inputIterator", "generateInnerIterableSync", "innerIterableDone", "valueToYieldMaybe", "generateOuterIterableSync", "firstNext", "nextIn", "itr8FromIterable", "generateInnerIterableAsync", "generateOuterIterableAsync", "isPromise", "filter", "filterFn", "generateNextFnResultFromFilterFnResult", "firstFilterFnResult", "nextIn", "f", "filterFnResult", "isPromise", "resultPromise", "result", "powerMapWithoutDoAfter", "_state", "flatten", "powerMapWithoutDoAfter", "nextIn", "_state", "groupPer", "groupSize", "powerMapWithoutDoAfter", "nextIn", "state", "identity", "it", "itOut", "intersperse", "intersperseThing", "powerMapWithoutDoAfter", "nextIn", "state", "peek", "peekForward", "peekBackward", "powerMapWithoutDoAfter", "nextIn", "state", "firstOfNext", "restOfNext", "newState", "reduce", "reducer", "initialValue", "powerMapWithoutDoAfter", "nextIn", "state", "acc", "thenable", "reduced", "repeat", "count", "powerMapWithoutDoAfter", "nextIn", "list", "remaining", "repeatEach", "count", "powerMapWithoutDoAfter", "nextIn", "_state", "i", "runningReduce", "reducer", "initialValue", "powerMapWithoutDoAfter", "nextIn", "state", "acc", "thenable", "reduced", "skip", "params", "powerMapWithoutDoAfter", "nextIn", "state", "skipWhile", "whileFn", "powerMapWithoutDoAfter", "nextIn", "state", "thenable", "keepSkipping", "_isSync", "sort", "sortFn", "powerMapWithoutDoAfter", "nextIn", "state", "split", "delimiter", "powerMapWithoutDoAfter", "nextIn", "state", "take", "count", "powerMapWithoutDoAfter", "nextIn", "state", "newState", "tap", "tapFn", "powerMapWithoutDoAfter", "nextIn", "_state", "e", "uniq", "powerMapWithoutDoAfter", "nextIn", "state", "newState", "uniqBy", "mapFn", "powerMapWithoutDoAfter", "nextIn", "state", "hash", "newState", "zip", "secondIterator", "powerMapWithoutDoAfter", "nextIn", "_state", "thenable", "secondNext", "average", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newSum", "max", "powerMapWithoutDoAfter", "nextIn", "state", "min", "powerMapWithoutDoAfter", "nextIn", "state", "percentile", "percentage", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newTopArraySize", "newTopArray", "b", "runningAverage", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newSum", "runningPercentile", "percentage", "powerMapWithoutDoAfter", "nextIn", "state", "newCount", "newTopArraySize", "newTopArray", "b", "runningTotal", "powerMapWithoutDoAfter", "nextIn", "state", "newTotal", "total", "powerMapWithoutDoAfter", "nextIn", "state", "lineByLine", "splitBy", "powerMapWithoutDoAfter", "nextIn", "done", "buffer", "lines", "stringToChar", "powerMapWithoutDoAfter", "nextIn", "_state", "itr8FromString", "debounce", "cooldownMilliseconds", "getTimestamp", "_value", "powerMapWithoutDoAfter", "nextIn", "state", "newState", "delay", "timeout", "powerMapWithoutDoAfter", "nextIn", "_state", "resolve", "throttle", "throttleMilliseconds", "getTimestamp", "_value", "powerMapWithoutDoAfter", "nextIn", "state", "now"] } diff --git a/dist/operators/general/branchAndMerge.d.ts b/dist/operators/general/branchAndMerge.d.ts index 1ab54cf..5230f1a 100644 --- a/dist/operators/general/branchAndMerge.d.ts +++ b/dist/operators/general/branchAndMerge.d.ts @@ -55,7 +55,7 @@ import { TTransIteratorSyncOrAsync } from "../../types.js"; * @param {...(it:Iterator | AsyncIterator)=>Iterator | AsyncIterator} moreTransIts * @returns * - * @category operators/async + * @category operators/general */ declare function branchAndMerge(transIt1: TTransIteratorSyncOrAsync): TTransIteratorSyncOrAsync; declare function branchAndMerge(transIt1: TTransIteratorSyncOrAsync, transIt2: TTransIteratorSyncOrAsync): TTransIteratorSyncOrAsync; diff --git a/dist/operators/general/distribute.d.ts b/dist/operators/general/distribute.d.ts new file mode 100644 index 0000000..856d874 --- /dev/null +++ b/dist/operators/general/distribute.d.ts @@ -0,0 +1,88 @@ +import { TTransIteratorSyncOrAsync } from "../../types.js"; +/** + * This operator should make it easy to distribute different categories on the input iterator, + * to multiple child iterators for further processing per category. + * The child iterator depends on the 'category' that is determined by the first element + * of the tuple. + * + * Imagine things like: I need to calculate the averages 'per schoolyear'. + * That would mean, categorize per schoolyear, and then calculate the average + * of the inner iterators by using a map after distribute. + * + * If you are not going to use all output iterators, make sure to filter out + * the categories you don't need before using distribute, because otherwise an unused + * buffer will be held needlessly in memory. + * + * The category is compared using simple equality checks, so strings and numbers are an easy fit. + * If you need more complex categories (like an array), make sure to return the same instance + * as the category. (Maybe we should create a 'categorize' or 'groupBy' operator that + * can help with dealing with more complex categories?) + * + * Questions: + * - Imagine you use it to categorize http requests (for example by sender ip/port), + * how do we 'close' a channel after a while so we can avoid the memory to keep growing? + * I mean, after some time you'll assume that the same 'sender' has done, and the output terator's + * next() call should return { done: true }. Would that be a setting, + * like the (unfinished) 'abandoned timeout' in the 'multiIterable' operator? + * - It could make sense to create a version that can handle multiple categories per value. + * Like for instance: divisible by 2, divisible by 3, divisible by 5, etc. + * where some values can be in multiple categories. + * This could also be done by making a categorize operator that can produce multiple tuples + * for each input, which would keep this operator simple. + * + * ``` + * ┌───────────────────────────────────────────────────────────┐ + * │input iterator with tuples of the form [ category, value ] | + * └──────┬────────────────────────────────────────────────────┘ + * │ + * ┌──────▼───────────────────────┐ + * │ output iterator of iterators │ + * │ (1 next() for each category) │ + * └──────────────────────────────┘ + * ├─────────────────────────────┐────────────────────── ... + * │ │ + * ┌────▼─────────────────────┐ ┌────▼─────────────────────┐ + * │ [ category 1, iterator ] │ │ [ category 2, iterator ] │ + * └────┬─────────────────────┘ └──────────────────────────┘ + * │ + * │ + * ┌──────▼──────────────────────────┐ + * │ forEach([ cetegory, iterator ]) │ + * └─────────────────────────────────┘ + * | + * ↳ pipe( iterator, ) + * ``` + * + * @example + * ```typescript + * await pipe( + * itr8ange(1, 1000), + * map( (v) => [ v % 2 === 0 ? 'even' : 'odd', v ] as [string, number] ), // add the category to the value + * // adding the category first allows us to easily filter out categories we don't need + * distribute(), + * map(([category, iterator]) => ({ + * category, + * values: pipe( + * iterator, + * take(2), + * toArray, + * ), + * })), + * itr8ToArray, + * ) + * // => [ + * // { category: 'odd', values: [ 1, 3 ] }, + * // { category: 'even', values: [ 2, 4 ] }, + * // ] + * ``` + * + * @category operators/general + */ +declare function distribute(): TTransIteratorSyncOrAsync<[ + C, + T +], [ + C, + IterableIterator | AsyncIterableIterator +]>; +export { distribute }; diff --git a/dist/operators/general/distribute.js b/dist/operators/general/distribute.js new file mode 100644 index 0000000..2a21af0 --- /dev/null +++ b/dist/operators/general/distribute.js @@ -0,0 +1,205 @@ +import { itr8FromIterable } from "../../interface/index.js"; +import { isPromise } from "../../util/index.js"; +/** + * This operator should make it easy to distribute different categories on the input iterator, + * to multiple child iterators for further processing per category. + * The child iterator depends on the 'category' that is determined by the first element + * of the tuple. + * + * Imagine things like: I need to calculate the averages 'per schoolyear'. + * That would mean, categorize per schoolyear, and then calculate the average + * of the inner iterators by using a map after distribute. + * + * If you are not going to use all output iterators, make sure to filter out + * the categories you don't need before using distribute, because otherwise an unused + * buffer will be held needlessly in memory. + * + * The category is compared using simple equality checks, so strings and numbers are an easy fit. + * If you need more complex categories (like an array), make sure to return the same instance + * as the category. (Maybe we should create a 'categorize' or 'groupBy' operator that + * can help with dealing with more complex categories?) + * + * Questions: + * - Imagine you use it to categorize http requests (for example by sender ip/port), + * how do we 'close' a channel after a while so we can avoid the memory to keep growing? + * I mean, after some time you'll assume that the same 'sender' has done, and the output terator's + * next() call should return { done: true }. Would that be a setting, + * like the (unfinished) 'abandoned timeout' in the 'multiIterable' operator? + * - It could make sense to create a version that can handle multiple categories per value. + * Like for instance: divisible by 2, divisible by 3, divisible by 5, etc. + * where some values can be in multiple categories. + * This could also be done by making a categorize operator that can produce multiple tuples + * for each input, which would keep this operator simple. + * + * ``` + * ┌───────────────────────────────────────────────────────────┐ + * │input iterator with tuples of the form [ category, value ] | + * └──────┬────────────────────────────────────────────────────┘ + * │ + * ┌──────▼───────────────────────┐ + * │ output iterator of iterators │ + * │ (1 next() for each category) │ + * └──────────────────────────────┘ + * ├─────────────────────────────┐────────────────────── ... + * │ │ + * ┌────▼─────────────────────┐ ┌────▼─────────────────────┐ + * │ [ category 1, iterator ] │ │ [ category 2, iterator ] │ + * └────┬─────────────────────┘ └──────────────────────────┘ + * │ + * │ + * ┌──────▼──────────────────────────┐ + * │ forEach([ cetegory, iterator ]) │ + * └─────────────────────────────────┘ + * | + * ↳ pipe( iterator, ) + * ``` + * + * @example + * ```typescript + * await pipe( + * itr8ange(1, 1000), + * map( (v) => [ v % 2 === 0 ? 'even' : 'odd', v ] as [string, number] ), // add the category to the value + * // adding the category first allows us to easily filter out categories we don't need + * distribute(), + * map(([category, iterator]) => ({ + * category, + * values: pipe( + * iterator, + * take(2), + * toArray, + * ), + * })), + * itr8ToArray, + * ) + * // => [ + * // { category: 'odd', values: [ 1, 3 ] }, + * // { category: 'even', values: [ 2, 4 ] }, + * // ] + * ``` + * + * @category operators/general + */ +function distribute() { + const bufferMap = new Map(); + // we need an ordered list in order to respond to next calls on the outer iterator + const categoriesArray = []; + let categoriesIndex = -1; + let distributionDone = false; + const addToCategory = (category, value) => { + if (bufferMap.has(category)) { + bufferMap.get(category).push(value); + } + else { + bufferMap.set(category, [value]); + categoriesArray.push(category); + } + }; + /** + * It will return the first value from the buffer of the given category, + * and update the buffer at the same time. + * + * @param category + * @returns the value from the buffer, or Symbol['categoryEmpty'] + */ + const getFromCategory = (category) => { + if (bufferMap.has(category)) { + const buffer = bufferMap.get(category); + if (buffer && buffer.length > 0) { + return buffer.shift(); + } + } + return Symbol["categoryEmpty"]; + }; + /** + * The function that will categorize the input iterator's values and update the internal state. + * @param itResult + */ + const distributeIn = (itResult) => { + if (itResult.done) { + distributionDone = true; + } + else { + addToCategory(itResult.value[0], itResult.value[1]); + } + }; + return (inputIterator) => { + function* generateInnerIterableSync(category) { + if (!bufferMap.has(category)) { + throw new Error(`Category ${category} not found in bufferMap`); + } + let innerIterableDone = false; + while (!innerIterableDone) { + const valueToYieldMaybe = getFromCategory(category); + if (valueToYieldMaybe !== Symbol["categoryEmpty"]) { + yield valueToYieldMaybe; + } + else if (distributionDone) { + innerIterableDone = true; + } + else { + distributeIn(inputIterator.next()); + } + } + } + /** + * This function is a generator that will categorize the input iterator's values + * and returns [category, iterator] tuples. + */ + function* generateOuterIterableSync(firstNext) { + for (let nextIn = firstNext; !nextIn.done; nextIn = inputIterator.next()) { + distributeIn(nextIn); + while (categoriesIndex < categoriesArray.length - 1) { + categoriesIndex += 1; + const category = categoriesArray[categoriesIndex]; + yield [ + category, + itr8FromIterable(generateInnerIterableSync(category)), + ]; + } + } + distributionDone = true; + } + async function* generateInnerIterableAsync(category) { + if (!bufferMap.has(category)) { + throw new Error(`Category ${category} not found in bufferMap`); + } + let innerIterableDone = false; + while (!innerIterableDone) { + const valueToYieldMaybe = getFromCategory(category); + if (valueToYieldMaybe !== Symbol["categoryEmpty"]) { + yield valueToYieldMaybe; + } + else if (distributionDone) { + innerIterableDone = true; + } + else { + distributeIn((await inputIterator.next())); + } + } + } + /** + * This function is a generator that will categorize the input iterator's values + * and returns [category, iterator] tuples. + */ + async function* generateOuterIterableAsync(firstNext) { + for (let nextIn = await firstNext; !nextIn.done; nextIn = await inputIterator.next()) { + distributeIn(nextIn); + while (categoriesIndex < categoriesArray.length - 1) { + categoriesIndex += 1; + const category = categoriesArray[categoriesIndex]; + yield [ + category, + itr8FromIterable(generateInnerIterableAsync(category)), + ]; + } + } + distributionDone = true; + } + const firstNext = inputIterator.next(); + return isPromise(firstNext) + ? generateOuterIterableAsync(firstNext) + : generateOuterIterableSync(firstNext); + }; +} +export { distribute }; +//# sourceMappingURL=distribute.js.map \ No newline at end of file diff --git a/dist/operators/general/distribute.js.map b/dist/operators/general/distribute.js.map new file mode 100644 index 0000000..705ed04 --- /dev/null +++ b/dist/operators/general/distribute.js.map @@ -0,0 +1 @@ +{"version":3,"file":"distribute.js","sourceRoot":"","sources":["../../../src/operators/general/distribute.ts"],"names":[],"mappings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S,CAAC,SAAS,CAAC;YACzB,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC;YACvC,CAAC,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/operators/general/filter.js.map b/dist/operators/general/filter.js.map index c7123c2..cc9ad55 100644 --- a/dist/operators/general/filter.js.map +++ b/dist/operators/general/filter.js.map @@ -1 +1 @@ -{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/operators/general/filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,CAAM,QAAgD,EAAE,EAAE;IACvE,8EAA8E;IAC9E,IAAI,sCAAsC,GAAG,UAC3C,mBAA+C,EAC/C,MAAM;QAEN,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAgC,EAAE,EAAE;YAC7D,IAAI,cAAc,EAAE;gBAClB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAW,CAAC;aACtD;iBAAM;gBACL,OAAO,EAAE,IAAI,EAAE,KAAK,EAAW,CAAC;aACjC;QACH,CAAC,CAAC;QAEF,sCAAsC,GAAG,SAAS,CAAC,mBAAmB,CAAC;YACrE,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CACvB,aAAkC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAClD,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAClB;YACL,CAAC,CAAC,CAAC,CAAC;QACN,OAAO,sCAAsC,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC;IAEF,OAAO,QAAQ,CACb,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACjB,IAAI,MAAM,CAAC,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAEvC,OAAO,sCAAsC,CAC3C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EACtB,MAAM,CACP,CAAC;QAEF,qDAAqD;QACrD,6DAA6D;QAC7D,6DAA6D;QAC7D,4BAA4B;QAC5B,UAAU;QAEV,yCAAyC;QACzC,2BAA2B;QAC3B,0BAA0B;QAC1B,qEAAqE;QACrE,8BAA8B;QAC9B,UAAU;QACV,WAAW;QACX,6DAA6D;QAC7D,4BAA4B;QAC5B,IAAI;IACN,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/operators/general/filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,CAAM,QAAgD,EAAE,EAAE;IACvE,8EAA8E;IAC9E,IAAI,sCAAsC,GAAG,UAC3C,mBAA+C,EAC/C,MAAM;QAEN,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAgC,EAAE,EAAE;YAC7D,IAAI,cAAc,EAAE;gBAClB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAW,CAAC;aACtD;iBAAM;gBACL,OAAO,EAAE,IAAI,EAAE,KAAK,EAAW,CAAC;aACjC;QACH,CAAC,CAAC;QAEF,sCAAsC,GAAG,SAAS,CAAC,mBAAmB,CAAC;YACrE,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,CACvB,aAAkC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAClD,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAClB;YACL,CAAC,CAAC,CAAC,CAAC;QACN,OAAO,sCAAsC,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC,CAAC;IAEF,OAAO,QAAQ,CACb,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACjB,IAAI,MAAM,CAAC,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAEvC,OAAO,sCAAsC,CAC3C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EACtB,MAAM,CACP,CAAC;QAEF,qDAAqD;QACrD,6DAA6D;QAC7D,6DAA6D;QAC7D,4BAA4B;QAC5B,UAAU;QAEV,yCAAyC;QACzC,2BAA2B;QAC3B,0BAA0B;QAC1B,qEAAqE;QACrE,8BAA8B;QAC9B,UAAU;QACV,WAAW;QACX,6DAA6D;QAC7D,4BAA4B;QAC5B,IAAI;IACN,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/operators/general/identity.js.map b/dist/operators/general/identity.js.map index 85e6d20..3915598 100644 --- a/dist/operators/general/identity.js.map +++ b/dist/operators/general/identity.js.map @@ -1 +1 @@ -{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/operators/general/identity.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ;IACf,OAAO,UACL,EAAkC;QAElC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YAC5B,OAAO,EAA8B,CAAC;SACvC;aAAM,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO,EAAyB,CAAC;SAClC;aAAM;YACL,MAAM,KAAK,GAAwB;gBACjC,IAAI,EAAE,EAAE,CAAC,IAA+B;gBACxC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK;aAC/B,CAAC;YACF,OAAO,KAAK,CAAC;SACd;IACH,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/operators/general/identity.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,SAAS,QAAQ;IACf,OAAO,UACL,EAAkC;QAElC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YAC5B,OAAO,EAA8B,CAAC;SACvC;aAAM,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;YAC9B,OAAO,EAAyB,CAAC;SAClC;aAAM;YACL,MAAM,KAAK,GAAwB;gBACjC,IAAI,EAAE,EAAE,CAAC,IAA+B;gBACxC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK;aAC/B,CAAC;YACF,OAAO,KAAK,CAAC;SACd;IACH,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/operators/general/index.d.ts b/dist/operators/general/index.d.ts index 7ca2742..617e56d 100644 --- a/dist/operators/general/index.d.ts +++ b/dist/operators/general/index.d.ts @@ -1,5 +1,6 @@ export * from "./branchAndMerge.js"; export * from "./dedup.js"; +export * from "./distribute.js"; export * from "./filter.js"; export * from "./flatten.js"; export * from "./groupPer.js"; diff --git a/dist/operators/general/index.js b/dist/operators/general/index.js index 943a041..20e58ed 100644 --- a/dist/operators/general/index.js +++ b/dist/operators/general/index.js @@ -1,5 +1,6 @@ export * from "./branchAndMerge.js"; export * from "./dedup.js"; +export * from "./distribute.js"; export * from "./filter.js"; export * from "./flatten.js"; export * from "./groupPer.js"; diff --git a/dist/operators/general/index.js.map b/dist/operators/general/index.js.map index cca5293..81f0ea4 100644 --- a/dist/operators/general/index.js.map +++ b/dist/operators/general/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/operators/general/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AAEpC,cAAc,YAAY,CAAC;AAE3B,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAE7B,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC;AAE9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAE1B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAE5B,cAAc,aAAa,CAAC;AAE5B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,WAAW,CAAC;AAE1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,WAAW,CAAC;AAE1B,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAE1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAE1B,cAAc,aAAa,CAAC;AAE5B,cAAc,UAAU,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/operators/general/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AAEpC,cAAc,YAAY,CAAC;AAE3B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,aAAa,CAAC;AAE5B,cAAc,cAAc,CAAC;AAE7B,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC;AAE9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAE1B,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC;AAE5B,cAAc,aAAa,CAAC;AAE5B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,WAAW,CAAC;AAE1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,WAAW,CAAC;AAE1B,cAAc,YAAY,CAAC;AAE3B,cAAc,WAAW,CAAC;AAE1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAE1B,cAAc,aAAa,CAAC;AAE5B,cAAc,UAAU,CAAC"} \ No newline at end of file diff --git a/dist/operators/general/tap.d.ts b/dist/operators/general/tap.d.ts index b6b645a..34aee67 100644 --- a/dist/operators/general/tap.d.ts +++ b/dist/operators/general/tap.d.ts @@ -6,5 +6,5 @@ * * @category operators/general */ -declare const tap: (tapFn: (TIn: any) => void) => import("../../types.js").TTransIteratorSyncOrAsync; +declare const tap: (tapFn: (value: TIn) => void) => import("../../types.js").TTransIteratorSyncOrAsync; export { tap }; diff --git a/dist/operators/general/tap.js.map b/dist/operators/general/tap.js.map index fa4ecc0..6948f15 100644 --- a/dist/operators/general/tap.js.map +++ b/dist/operators/general/tap.js.map @@ -1 +1 @@ -{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../src/operators/general/tap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,GAAG,GAAG,CAAM,KAAoB,EAAE,EAAE,CACxC,QAAQ,CACN,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IACjB,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACvB;SAAM;QACL,IAAI;YACF,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;KAC7C;AACH,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AAEJ,OAAO,EAAE,GAAG,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"tap.js","sourceRoot":"","sources":["../../../src/operators/general/tap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,GAAG,GAAG,CAAM,KAA2B,EAAE,EAAE,CAC/C,QAAQ,CACN,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IACjB,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;KACvB;SAAM;QACL,IAAI;YACF,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;KAC7C;AACH,CAAC,EACD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;AAEJ,OAAO,EAAE,GAAG,EAAE,CAAC"} \ No newline at end of file diff --git a/docs/assets/search.js b/docs/assets/search.js index 5a0139e..6183280 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = JSON.parse("{\"kinds\":{\"2\":\"Module\",\"32\":\"Variable\",\"64\":\"Function\",\"1024\":\"Property\",\"65536\":\"Type literal\",\"4194304\":\"Type alias\",\"8388608\":\"Reference\",\"33554432\":\"@knodes/typedoc-plugin-pages: page\"},\"rows\":[{\"kind\":2,\"name\":\"interface\",\"url\":\"modules/interface.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":2,\"name\":\"operators\",\"url\":\"modules/operators.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":2,\"name\":\"util\",\"url\":\"modules/util.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":64,\"name\":\"compose\",\"url\":\"functions/util.compose.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-1.__type-2\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-2.__type-4\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-3.__type-6\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-4.__type-8\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-5.__type-10\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-6.__type-12\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-7.__type-14\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-8.__type-16\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-9.__type-18\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-10.__type-20\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":8388608,\"name\":\"itr8Pipe\",\"url\":\"modules/util.html#itr8Pipe\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"pipe\",\"url\":\"functions/util.pipe.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"isPromise\",\"url\":\"functions/util.isPromise.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":32,\"name\":\"AsyncFunction\",\"url\":\"variables/util.AsyncFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"thenable\",\"url\":\"functions/util.thenable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"thenableFactory\",\"url\":\"functions/util.thenableFactory.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.thenableFactory.html#thenableFactory.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.thenableFactory.thenableFactory\"},{\"kind\":64,\"name\":\"doAfter\",\"url\":\"functions/util.doAfter.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfter.html#doAfter.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.doAfter.doAfter\"},{\"kind\":64,\"name\":\"doAfterFactory\",\"url\":\"functions/util.doAfterFactory.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory\"},{\"kind\":1024,\"name\":\"doAfter\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.doAfter\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.doAfter.__type-3\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type.doAfter\"},{\"kind\":1024,\"name\":\"asyncDoAfter\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.asyncDoAfter\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.asyncDoAfter.__type-1\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type.asyncDoAfter\"},{\"kind\":1024,\"name\":\"syncDoAfter\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.syncDoAfter\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.syncDoAfter.__type-5\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type.syncDoAfter\"},{\"kind\":64,\"name\":\"forLoop\",\"url\":\"functions/util.forLoop.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":2,\"name\":\"index\",\"url\":\"modules/index.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":2,\"name\":\"peer\",\"url\":\"modules/peer.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":64,\"name\":\"forEach\",\"url\":\"functions/interface.forEach.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/interface.forEach.html#forEach.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"interface.forEach.forEach\"},{\"kind\":64,\"name\":\"itr8FromArray\",\"url\":\"functions/interface.itr8FromArray.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromArrayAsync\",\"url\":\"functions/interface.itr8FromArrayAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromImpureFunction\",\"url\":\"functions/interface.itr8FromImpureFunction.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromIterable\",\"url\":\"functions/interface.itr8FromIterable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromSingleValue\",\"url\":\"functions/interface.itr8FromSingleValue.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromSingleValueAsync\",\"url\":\"functions/interface.itr8FromSingleValueAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromString\",\"url\":\"functions/interface.itr8FromString.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromStringAsync\",\"url\":\"functions/interface.itr8FromStringAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8Interval\",\"url\":\"functions/interface.itr8Interval.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8Pushable\",\"url\":\"functions/interface.itr8Pushable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8Range\",\"url\":\"functions/interface.itr8Range.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8RangeAsync\",\"url\":\"functions/interface.itr8RangeAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToArray\",\"url\":\"functions/interface.itr8ToArray.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToObject\",\"url\":\"functions/interface.itr8ToObject.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToString\",\"url\":\"functions/interface.itr8ToString.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToMultiIterable\",\"url\":\"functions/interface.itr8ToMultiIterable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"mostRecent\",\"url\":\"functions/operators.mostRecent.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/operators.mostRecent.html#mostRecent.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"operators.mostRecent.mostRecent\"},{\"kind\":64,\"name\":\"prefetch\",\"url\":\"functions/operators.prefetch.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/operators.prefetch.html#prefetch.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"operators.prefetch.prefetch\"},{\"kind\":64,\"name\":\"parallel\",\"url\":\"functions/operators.parallel.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"every\",\"url\":\"functions/operators.every.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"some\",\"url\":\"functions/operators.some.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"branchAndMerge\",\"url\":\"functions/operators.branchAndMerge.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"dedup\",\"url\":\"functions/operators.dedup.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"filter\",\"url\":\"functions/operators.filter.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"flatten\",\"url\":\"functions/operators.flatten.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"groupPer\",\"url\":\"functions/operators.groupPer.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"identity\",\"url\":\"functions/operators.identity.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"intersperse\",\"url\":\"functions/operators.intersperse.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"map\",\"url\":\"functions/operators.map.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"peek\",\"url\":\"functions/operators.peek.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"powerMap\",\"url\":\"functions/operators.powerMap.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"reduce\",\"url\":\"functions/operators.reduce.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"repeat\",\"url\":\"functions/operators.repeat.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"repeatEach\",\"url\":\"functions/operators.repeatEach.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningReduce\",\"url\":\"functions/operators.runningReduce.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"skip\",\"url\":\"functions/operators.skip.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"skipWhile\",\"url\":\"functions/operators.skipWhile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"sort\",\"url\":\"functions/operators.sort.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"split\",\"url\":\"functions/operators.split.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"take\",\"url\":\"functions/operators.take.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"takeWhile\",\"url\":\"functions/operators.takeWhile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"tap\",\"url\":\"functions/operators.tap.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"uniq\",\"url\":\"functions/operators.uniq.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"uniqBy\",\"url\":\"functions/operators.uniqBy.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"zip\",\"url\":\"functions/operators.zip.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"average\",\"url\":\"functions/operators.average.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"max\",\"url\":\"functions/operators.max.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"min\",\"url\":\"functions/operators.min.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"percentile\",\"url\":\"functions/operators.percentile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningAverage\",\"url\":\"functions/operators.runningAverage.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningPercentile\",\"url\":\"functions/operators.runningPercentile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningTotal\",\"url\":\"functions/operators.runningTotal.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"total\",\"url\":\"functions/operators.total.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"lineByLine\",\"url\":\"functions/operators.lineByLine.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"stringToChar\",\"url\":\"functions/operators.stringToChar.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"debounce\",\"url\":\"functions/operators.debounce.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"delay\",\"url\":\"functions/operators.delay.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"throttle\",\"url\":\"functions/operators.throttle.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":4194304,\"name\":\"TPushable\",\"url\":\"types/index.TPushable.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TPushable.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"index.TPushable\"},{\"kind\":1024,\"name\":\"push\",\"url\":\"types/index.TPushable.html#__type.push\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TPushable.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TPushable.html#__type.push.__type-3\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"index.TPushable.__type.push\"},{\"kind\":1024,\"name\":\"done\",\"url\":\"types/index.TPushable.html#__type.done\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TPushable.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TPushable.html#__type.done.__type-1\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"index.TPushable.__type.done\"},{\"kind\":4194304,\"name\":\"TTransIteratorSyncOrAsync\",\"url\":\"types/index.TTransIteratorSyncOrAsync.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TTransIteratorSyncOrAsync.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"index.TTransIteratorSyncOrAsync\"},{\"kind\":4194304,\"name\":\"TNextFnResult\",\"url\":\"types/index.TNextFnResult.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":4194304,\"name\":\"TThenable\",\"url\":\"types/index.TThenable.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TThenable.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"index.TThenable\"},{\"kind\":1024,\"name\":\"src\",\"url\":\"types/index.TThenable.html#__type.src\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TThenable.__type\"},{\"kind\":1024,\"name\":\"then\",\"url\":\"types/index.TThenable.html#__type.then\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TThenable.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TThenable.html#__type.then.__type-1\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"index.TThenable.__type.then\"},{\"kind\":1024,\"name\":\"value\",\"url\":\"types/index.TThenable.html#__type.value\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TThenable.__type\"},{\"kind\":8388608,\"name\":\"compose\",\"url\":\"modules/index.html#compose\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Pipe\",\"url\":\"modules/index.html#itr8Pipe\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"pipe\",\"url\":\"modules/index.html#pipe\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"isPromise\",\"url\":\"modules/index.html#isPromise\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"AsyncFunction\",\"url\":\"modules/index.html#AsyncFunction\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"thenable\",\"url\":\"modules/index.html#thenable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"thenableFactory\",\"url\":\"modules/index.html#thenableFactory\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"doAfter\",\"url\":\"modules/index.html#doAfter\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"doAfterFactory\",\"url\":\"modules/index.html#doAfterFactory\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"forLoop\",\"url\":\"modules/index.html#forLoop\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"forEach\",\"url\":\"modules/index.html#forEach\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromArray\",\"url\":\"modules/index.html#itr8FromArray\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromArrayAsync\",\"url\":\"modules/index.html#itr8FromArrayAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromImpureFunction\",\"url\":\"modules/index.html#itr8FromImpureFunction\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromIterable\",\"url\":\"modules/index.html#itr8FromIterable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromSingleValue\",\"url\":\"modules/index.html#itr8FromSingleValue\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromSingleValueAsync\",\"url\":\"modules/index.html#itr8FromSingleValueAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromString\",\"url\":\"modules/index.html#itr8FromString\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromStringAsync\",\"url\":\"modules/index.html#itr8FromStringAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Interval\",\"url\":\"modules/index.html#itr8Interval\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Pushable\",\"url\":\"modules/index.html#itr8Pushable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Range\",\"url\":\"modules/index.html#itr8Range\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8RangeAsync\",\"url\":\"modules/index.html#itr8RangeAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToArray\",\"url\":\"modules/index.html#itr8ToArray\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToObject\",\"url\":\"modules/index.html#itr8ToObject\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToString\",\"url\":\"modules/index.html#itr8ToString\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToMultiIterable\",\"url\":\"modules/index.html#itr8ToMultiIterable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"mostRecent\",\"url\":\"modules/index.html#mostRecent\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"prefetch\",\"url\":\"modules/index.html#prefetch\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"parallel\",\"url\":\"modules/index.html#parallel\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"every\",\"url\":\"modules/index.html#every\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"some\",\"url\":\"modules/index.html#some\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"branchAndMerge\",\"url\":\"modules/index.html#branchAndMerge\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"dedup\",\"url\":\"modules/index.html#dedup\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"filter\",\"url\":\"modules/index.html#filter\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"flatten\",\"url\":\"modules/index.html#flatten\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"groupPer\",\"url\":\"modules/index.html#groupPer\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"identity\",\"url\":\"modules/index.html#identity\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"intersperse\",\"url\":\"modules/index.html#intersperse\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"map\",\"url\":\"modules/index.html#map\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"peek\",\"url\":\"modules/index.html#peek\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"powerMap\",\"url\":\"modules/index.html#powerMap\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"reduce\",\"url\":\"modules/index.html#reduce\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"repeat\",\"url\":\"modules/index.html#repeat\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"repeatEach\",\"url\":\"modules/index.html#repeatEach\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningReduce\",\"url\":\"modules/index.html#runningReduce\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"skip\",\"url\":\"modules/index.html#skip\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"skipWhile\",\"url\":\"modules/index.html#skipWhile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"sort\",\"url\":\"modules/index.html#sort\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"split\",\"url\":\"modules/index.html#split\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"take\",\"url\":\"modules/index.html#take\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"takeWhile\",\"url\":\"modules/index.html#takeWhile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"tap\",\"url\":\"modules/index.html#tap\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"uniq\",\"url\":\"modules/index.html#uniq\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"uniqBy\",\"url\":\"modules/index.html#uniqBy\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"zip\",\"url\":\"modules/index.html#zip\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"average\",\"url\":\"modules/index.html#average\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"max\",\"url\":\"modules/index.html#max\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"min\",\"url\":\"modules/index.html#min\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"percentile\",\"url\":\"modules/index.html#percentile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningAverage\",\"url\":\"modules/index.html#runningAverage\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningPercentile\",\"url\":\"modules/index.html#runningPercentile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningTotal\",\"url\":\"modules/index.html#runningTotal\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"total\",\"url\":\"modules/index.html#total\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"lineByLine\",\"url\":\"modules/index.html#lineByLine\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"stringToChar\",\"url\":\"modules/index.html#stringToChar\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"debounce\",\"url\":\"modules/index.html#debounce\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"delay\",\"url\":\"modules/index.html#delay\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"throttle\",\"url\":\"modules/index.html#throttle\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":64,\"name\":\"itr8FromStream\",\"url\":\"functions/peer.itr8FromStream.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8ToReadableStream\",\"url\":\"functions/peer.itr8ToReadableStream.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8FromStdin\",\"url\":\"functions/peer.itr8FromStdin.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8FromObservable\",\"url\":\"functions/peer.itr8FromObservable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8ToObservable\",\"url\":\"functions/peer.itr8ToObservable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"parseJson\",\"url\":\"functions/peer.parseJson.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":33554432,\"name\":\"Change Log\",\"url\":\"pages/CHANGELOG.html\",\"classes\":\"pages-entry pages-entry-page\"},{\"kind\":33554432,\"name\":\"Roadmap\",\"url\":\"pages/ROADMAP.html\",\"classes\":\"pages-entry pages-entry-page\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,48.52]],[\"comment/0\",[]],[\"name/1\",[1,48.52]],[\"comment/1\",[]],[\"name/2\",[2,48.52]],[\"comment/2\",[]],[\"name/3\",[3,43.401]],[\"comment/3\",[]],[\"name/4\",[4,19.741]],[\"comment/4\",[]],[\"name/5\",[4,19.741]],[\"comment/5\",[]],[\"name/6\",[4,19.741]],[\"comment/6\",[]],[\"name/7\",[4,19.741]],[\"comment/7\",[]],[\"name/8\",[4,19.741]],[\"comment/8\",[]],[\"name/9\",[4,19.741]],[\"comment/9\",[]],[\"name/10\",[4,19.741]],[\"comment/10\",[]],[\"name/11\",[4,19.741]],[\"comment/11\",[]],[\"name/12\",[4,19.741]],[\"comment/12\",[]],[\"name/13\",[4,19.741]],[\"comment/13\",[]],[\"name/14\",[4,19.741]],[\"comment/14\",[]],[\"name/15\",[5,43.401]],[\"comment/15\",[]],[\"name/16\",[6,43.401]],[\"comment/16\",[]],[\"name/17\",[7,43.401]],[\"comment/17\",[]],[\"name/18\",[8,43.401]],[\"comment/18\",[]],[\"name/19\",[9,43.401]],[\"comment/19\",[]],[\"name/20\",[10,43.401]],[\"comment/20\",[]],[\"name/21\",[4,19.741]],[\"comment/21\",[]],[\"name/22\",[11,40.029]],[\"comment/22\",[]],[\"name/23\",[4,19.741]],[\"comment/23\",[]],[\"name/24\",[12,43.401]],[\"comment/24\",[]],[\"name/25\",[4,19.741]],[\"comment/25\",[]],[\"name/26\",[11,40.029]],[\"comment/26\",[]],[\"name/27\",[4,19.741]],[\"comment/27\",[]],[\"name/28\",[13,48.52]],[\"comment/28\",[]],[\"name/29\",[4,19.741]],[\"comment/29\",[]],[\"name/30\",[14,48.52]],[\"comment/30\",[]],[\"name/31\",[4,19.741]],[\"comment/31\",[]],[\"name/32\",[15,43.401]],[\"comment/32\",[]],[\"name/33\",[16,48.52]],[\"comment/33\",[]],[\"name/34\",[17,48.52]],[\"comment/34\",[]],[\"name/35\",[18,43.401]],[\"comment/35\",[]],[\"name/36\",[4,19.741]],[\"comment/36\",[]],[\"name/37\",[19,43.401]],[\"comment/37\",[]],[\"name/38\",[20,43.401]],[\"comment/38\",[]],[\"name/39\",[21,43.401]],[\"comment/39\",[]],[\"name/40\",[22,43.401]],[\"comment/40\",[]],[\"name/41\",[23,43.401]],[\"comment/41\",[]],[\"name/42\",[24,43.401]],[\"comment/42\",[]],[\"name/43\",[25,43.401]],[\"comment/43\",[]],[\"name/44\",[26,43.401]],[\"comment/44\",[]],[\"name/45\",[27,43.401]],[\"comment/45\",[]],[\"name/46\",[28,43.401]],[\"comment/46\",[]],[\"name/47\",[29,43.401]],[\"comment/47\",[]],[\"name/48\",[30,43.401]],[\"comment/48\",[]],[\"name/49\",[31,43.401]],[\"comment/49\",[]],[\"name/50\",[32,43.401]],[\"comment/50\",[]],[\"name/51\",[33,43.401]],[\"comment/51\",[]],[\"name/52\",[34,43.401]],[\"comment/52\",[]],[\"name/53\",[35,43.401]],[\"comment/53\",[]],[\"name/54\",[4,19.741]],[\"comment/54\",[]],[\"name/55\",[36,43.401]],[\"comment/55\",[]],[\"name/56\",[4,19.741]],[\"comment/56\",[]],[\"name/57\",[37,43.401]],[\"comment/57\",[]],[\"name/58\",[38,43.401]],[\"comment/58\",[]],[\"name/59\",[39,43.401]],[\"comment/59\",[]],[\"name/60\",[40,43.401]],[\"comment/60\",[]],[\"name/61\",[41,43.401]],[\"comment/61\",[]],[\"name/62\",[42,43.401]],[\"comment/62\",[]],[\"name/63\",[43,43.401]],[\"comment/63\",[]],[\"name/64\",[44,43.401]],[\"comment/64\",[]],[\"name/65\",[45,43.401]],[\"comment/65\",[]],[\"name/66\",[46,43.401]],[\"comment/66\",[]],[\"name/67\",[47,43.401]],[\"comment/67\",[]],[\"name/68\",[48,43.401]],[\"comment/68\",[]],[\"name/69\",[49,43.401]],[\"comment/69\",[]],[\"name/70\",[50,43.401]],[\"comment/70\",[]],[\"name/71\",[51,43.401]],[\"comment/71\",[]],[\"name/72\",[52,43.401]],[\"comment/72\",[]],[\"name/73\",[53,43.401]],[\"comment/73\",[]],[\"name/74\",[54,43.401]],[\"comment/74\",[]],[\"name/75\",[55,43.401]],[\"comment/75\",[]],[\"name/76\",[56,43.401]],[\"comment/76\",[]],[\"name/77\",[57,43.401]],[\"comment/77\",[]],[\"name/78\",[58,43.401]],[\"comment/78\",[]],[\"name/79\",[59,43.401]],[\"comment/79\",[]],[\"name/80\",[60,43.401]],[\"comment/80\",[]],[\"name/81\",[61,43.401]],[\"comment/81\",[]],[\"name/82\",[62,43.401]],[\"comment/82\",[]],[\"name/83\",[63,43.401]],[\"comment/83\",[]],[\"name/84\",[64,43.401]],[\"comment/84\",[]],[\"name/85\",[65,43.401]],[\"comment/85\",[]],[\"name/86\",[66,43.401]],[\"comment/86\",[]],[\"name/87\",[67,43.401]],[\"comment/87\",[]],[\"name/88\",[68,43.401]],[\"comment/88\",[]],[\"name/89\",[69,43.401]],[\"comment/89\",[]],[\"name/90\",[70,43.401]],[\"comment/90\",[]],[\"name/91\",[71,43.401]],[\"comment/91\",[]],[\"name/92\",[72,43.401]],[\"comment/92\",[]],[\"name/93\",[73,43.401]],[\"comment/93\",[]],[\"name/94\",[74,43.401]],[\"comment/94\",[]],[\"name/95\",[75,43.401]],[\"comment/95\",[]],[\"name/96\",[76,43.401]],[\"comment/96\",[]],[\"name/97\",[77,48.52]],[\"comment/97\",[]],[\"name/98\",[4,19.741]],[\"comment/98\",[]],[\"name/99\",[78,48.52]],[\"comment/99\",[]],[\"name/100\",[4,19.741]],[\"comment/100\",[]],[\"name/101\",[79,48.52]],[\"comment/101\",[]],[\"name/102\",[4,19.741]],[\"comment/102\",[]],[\"name/103\",[80,48.52]],[\"comment/103\",[]],[\"name/104\",[4,19.741]],[\"comment/104\",[]],[\"name/105\",[81,48.52]],[\"comment/105\",[]],[\"name/106\",[82,48.52]],[\"comment/106\",[]],[\"name/107\",[4,19.741]],[\"comment/107\",[]],[\"name/108\",[83,48.52]],[\"comment/108\",[]],[\"name/109\",[84,48.52]],[\"comment/109\",[]],[\"name/110\",[4,19.741]],[\"comment/110\",[]],[\"name/111\",[85,48.52]],[\"comment/111\",[]],[\"name/112\",[3,43.401]],[\"comment/112\",[]],[\"name/113\",[5,43.401]],[\"comment/113\",[]],[\"name/114\",[6,43.401]],[\"comment/114\",[]],[\"name/115\",[7,43.401]],[\"comment/115\",[]],[\"name/116\",[8,43.401]],[\"comment/116\",[]],[\"name/117\",[9,43.401]],[\"comment/117\",[]],[\"name/118\",[10,43.401]],[\"comment/118\",[]],[\"name/119\",[11,40.029]],[\"comment/119\",[]],[\"name/120\",[12,43.401]],[\"comment/120\",[]],[\"name/121\",[15,43.401]],[\"comment/121\",[]],[\"name/122\",[18,43.401]],[\"comment/122\",[]],[\"name/123\",[19,43.401]],[\"comment/123\",[]],[\"name/124\",[20,43.401]],[\"comment/124\",[]],[\"name/125\",[21,43.401]],[\"comment/125\",[]],[\"name/126\",[22,43.401]],[\"comment/126\",[]],[\"name/127\",[23,43.401]],[\"comment/127\",[]],[\"name/128\",[24,43.401]],[\"comment/128\",[]],[\"name/129\",[25,43.401]],[\"comment/129\",[]],[\"name/130\",[26,43.401]],[\"comment/130\",[]],[\"name/131\",[27,43.401]],[\"comment/131\",[]],[\"name/132\",[28,43.401]],[\"comment/132\",[]],[\"name/133\",[29,43.401]],[\"comment/133\",[]],[\"name/134\",[30,43.401]],[\"comment/134\",[]],[\"name/135\",[31,43.401]],[\"comment/135\",[]],[\"name/136\",[32,43.401]],[\"comment/136\",[]],[\"name/137\",[33,43.401]],[\"comment/137\",[]],[\"name/138\",[34,43.401]],[\"comment/138\",[]],[\"name/139\",[35,43.401]],[\"comment/139\",[]],[\"name/140\",[36,43.401]],[\"comment/140\",[]],[\"name/141\",[37,43.401]],[\"comment/141\",[]],[\"name/142\",[38,43.401]],[\"comment/142\",[]],[\"name/143\",[39,43.401]],[\"comment/143\",[]],[\"name/144\",[40,43.401]],[\"comment/144\",[]],[\"name/145\",[41,43.401]],[\"comment/145\",[]],[\"name/146\",[42,43.401]],[\"comment/146\",[]],[\"name/147\",[43,43.401]],[\"comment/147\",[]],[\"name/148\",[44,43.401]],[\"comment/148\",[]],[\"name/149\",[45,43.401]],[\"comment/149\",[]],[\"name/150\",[46,43.401]],[\"comment/150\",[]],[\"name/151\",[47,43.401]],[\"comment/151\",[]],[\"name/152\",[48,43.401]],[\"comment/152\",[]],[\"name/153\",[49,43.401]],[\"comment/153\",[]],[\"name/154\",[50,43.401]],[\"comment/154\",[]],[\"name/155\",[51,43.401]],[\"comment/155\",[]],[\"name/156\",[52,43.401]],[\"comment/156\",[]],[\"name/157\",[53,43.401]],[\"comment/157\",[]],[\"name/158\",[54,43.401]],[\"comment/158\",[]],[\"name/159\",[55,43.401]],[\"comment/159\",[]],[\"name/160\",[56,43.401]],[\"comment/160\",[]],[\"name/161\",[57,43.401]],[\"comment/161\",[]],[\"name/162\",[58,43.401]],[\"comment/162\",[]],[\"name/163\",[59,43.401]],[\"comment/163\",[]],[\"name/164\",[60,43.401]],[\"comment/164\",[]],[\"name/165\",[61,43.401]],[\"comment/165\",[]],[\"name/166\",[62,43.401]],[\"comment/166\",[]],[\"name/167\",[63,43.401]],[\"comment/167\",[]],[\"name/168\",[64,43.401]],[\"comment/168\",[]],[\"name/169\",[65,43.401]],[\"comment/169\",[]],[\"name/170\",[66,43.401]],[\"comment/170\",[]],[\"name/171\",[67,43.401]],[\"comment/171\",[]],[\"name/172\",[68,43.401]],[\"comment/172\",[]],[\"name/173\",[69,43.401]],[\"comment/173\",[]],[\"name/174\",[70,43.401]],[\"comment/174\",[]],[\"name/175\",[71,43.401]],[\"comment/175\",[]],[\"name/176\",[72,43.401]],[\"comment/176\",[]],[\"name/177\",[73,43.401]],[\"comment/177\",[]],[\"name/178\",[74,43.401]],[\"comment/178\",[]],[\"name/179\",[75,43.401]],[\"comment/179\",[]],[\"name/180\",[76,43.401]],[\"comment/180\",[]],[\"name/181\",[86,48.52]],[\"comment/181\",[]],[\"name/182\",[87,48.52]],[\"comment/182\",[]],[\"name/183\",[88,48.52]],[\"comment/183\",[]],[\"name/184\",[89,48.52]],[\"comment/184\",[]],[\"name/185\",[90,48.52]],[\"comment/185\",[]],[\"name/186\",[91,48.52]],[\"comment/186\",[]],[\"name/187\",[92,34.465,93,34.465]],[\"comment/187\",[]],[\"name/188\",[94,48.52]],[\"comment/188\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":4,\"name\":{\"4\":{},\"5\":{},\"6\":{},\"7\":{},\"8\":{},\"9\":{},\"10\":{},\"11\":{},\"12\":{},\"13\":{},\"14\":{},\"21\":{},\"23\":{},\"25\":{},\"27\":{},\"29\":{},\"31\":{},\"36\":{},\"54\":{},\"56\":{},\"98\":{},\"100\":{},\"102\":{},\"104\":{},\"107\":{},\"110\":{}},\"comment\":{}}],[\"asyncdoafter\",{\"_index\":13,\"name\":{\"28\":{}},\"comment\":{}}],[\"asyncfunction\",{\"_index\":8,\"name\":{\"18\":{},\"116\":{}},\"comment\":{}}],[\"average\",{\"_index\":64,\"name\":{\"84\":{},\"168\":{}},\"comment\":{}}],[\"branchandmerge\",{\"_index\":40,\"name\":{\"60\":{},\"144\":{}},\"comment\":{}}],[\"change\",{\"_index\":92,\"name\":{\"187\":{}},\"comment\":{}}],[\"compose\",{\"_index\":3,\"name\":{\"3\":{},\"112\":{}},\"comment\":{}}],[\"debounce\",{\"_index\":74,\"name\":{\"94\":{},\"178\":{}},\"comment\":{}}],[\"dedup\",{\"_index\":41,\"name\":{\"61\":{},\"145\":{}},\"comment\":{}}],[\"delay\",{\"_index\":75,\"name\":{\"95\":{},\"179\":{}},\"comment\":{}}],[\"doafter\",{\"_index\":11,\"name\":{\"22\":{},\"26\":{},\"119\":{}},\"comment\":{}}],[\"doafterfactory\",{\"_index\":12,\"name\":{\"24\":{},\"120\":{}},\"comment\":{}}],[\"done\",{\"_index\":79,\"name\":{\"101\":{}},\"comment\":{}}],[\"every\",{\"_index\":38,\"name\":{\"58\":{},\"142\":{}},\"comment\":{}}],[\"filter\",{\"_index\":42,\"name\":{\"62\":{},\"146\":{}},\"comment\":{}}],[\"flatten\",{\"_index\":43,\"name\":{\"63\":{},\"147\":{}},\"comment\":{}}],[\"foreach\",{\"_index\":18,\"name\":{\"35\":{},\"122\":{}},\"comment\":{}}],[\"forloop\",{\"_index\":15,\"name\":{\"32\":{},\"121\":{}},\"comment\":{}}],[\"groupper\",{\"_index\":44,\"name\":{\"64\":{},\"148\":{}},\"comment\":{}}],[\"identity\",{\"_index\":45,\"name\":{\"65\":{},\"149\":{}},\"comment\":{}}],[\"index\",{\"_index\":16,\"name\":{\"33\":{}},\"comment\":{}}],[\"interface\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"intersperse\",{\"_index\":46,\"name\":{\"66\":{},\"150\":{}},\"comment\":{}}],[\"ispromise\",{\"_index\":7,\"name\":{\"17\":{},\"115\":{}},\"comment\":{}}],[\"itr8fromarray\",{\"_index\":19,\"name\":{\"37\":{},\"123\":{}},\"comment\":{}}],[\"itr8fromarrayasync\",{\"_index\":20,\"name\":{\"38\":{},\"124\":{}},\"comment\":{}}],[\"itr8fromimpurefunction\",{\"_index\":21,\"name\":{\"39\":{},\"125\":{}},\"comment\":{}}],[\"itr8fromiterable\",{\"_index\":22,\"name\":{\"40\":{},\"126\":{}},\"comment\":{}}],[\"itr8fromobservable\",{\"_index\":89,\"name\":{\"184\":{}},\"comment\":{}}],[\"itr8fromsinglevalue\",{\"_index\":23,\"name\":{\"41\":{},\"127\":{}},\"comment\":{}}],[\"itr8fromsinglevalueasync\",{\"_index\":24,\"name\":{\"42\":{},\"128\":{}},\"comment\":{}}],[\"itr8fromstdin\",{\"_index\":88,\"name\":{\"183\":{}},\"comment\":{}}],[\"itr8fromstream\",{\"_index\":86,\"name\":{\"181\":{}},\"comment\":{}}],[\"itr8fromstring\",{\"_index\":25,\"name\":{\"43\":{},\"129\":{}},\"comment\":{}}],[\"itr8fromstringasync\",{\"_index\":26,\"name\":{\"44\":{},\"130\":{}},\"comment\":{}}],[\"itr8interval\",{\"_index\":27,\"name\":{\"45\":{},\"131\":{}},\"comment\":{}}],[\"itr8pipe\",{\"_index\":5,\"name\":{\"15\":{},\"113\":{}},\"comment\":{}}],[\"itr8pushable\",{\"_index\":28,\"name\":{\"46\":{},\"132\":{}},\"comment\":{}}],[\"itr8range\",{\"_index\":29,\"name\":{\"47\":{},\"133\":{}},\"comment\":{}}],[\"itr8rangeasync\",{\"_index\":30,\"name\":{\"48\":{},\"134\":{}},\"comment\":{}}],[\"itr8toarray\",{\"_index\":31,\"name\":{\"49\":{},\"135\":{}},\"comment\":{}}],[\"itr8tomultiiterable\",{\"_index\":34,\"name\":{\"52\":{},\"138\":{}},\"comment\":{}}],[\"itr8toobject\",{\"_index\":32,\"name\":{\"50\":{},\"136\":{}},\"comment\":{}}],[\"itr8toobservable\",{\"_index\":90,\"name\":{\"185\":{}},\"comment\":{}}],[\"itr8toreadablestream\",{\"_index\":87,\"name\":{\"182\":{}},\"comment\":{}}],[\"itr8tostring\",{\"_index\":33,\"name\":{\"51\":{},\"137\":{}},\"comment\":{}}],[\"linebyline\",{\"_index\":72,\"name\":{\"92\":{},\"176\":{}},\"comment\":{}}],[\"log\",{\"_index\":93,\"name\":{\"187\":{}},\"comment\":{}}],[\"map\",{\"_index\":47,\"name\":{\"67\":{},\"151\":{}},\"comment\":{}}],[\"max\",{\"_index\":65,\"name\":{\"85\":{},\"169\":{}},\"comment\":{}}],[\"min\",{\"_index\":66,\"name\":{\"86\":{},\"170\":{}},\"comment\":{}}],[\"mostrecent\",{\"_index\":35,\"name\":{\"53\":{},\"139\":{}},\"comment\":{}}],[\"operators\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"parallel\",{\"_index\":37,\"name\":{\"57\":{},\"141\":{}},\"comment\":{}}],[\"parsejson\",{\"_index\":91,\"name\":{\"186\":{}},\"comment\":{}}],[\"peek\",{\"_index\":48,\"name\":{\"68\":{},\"152\":{}},\"comment\":{}}],[\"peer\",{\"_index\":17,\"name\":{\"34\":{}},\"comment\":{}}],[\"percentile\",{\"_index\":67,\"name\":{\"87\":{},\"171\":{}},\"comment\":{}}],[\"pipe\",{\"_index\":6,\"name\":{\"16\":{},\"114\":{}},\"comment\":{}}],[\"powermap\",{\"_index\":49,\"name\":{\"69\":{},\"153\":{}},\"comment\":{}}],[\"prefetch\",{\"_index\":36,\"name\":{\"55\":{},\"140\":{}},\"comment\":{}}],[\"push\",{\"_index\":78,\"name\":{\"99\":{}},\"comment\":{}}],[\"reduce\",{\"_index\":50,\"name\":{\"70\":{},\"154\":{}},\"comment\":{}}],[\"repeat\",{\"_index\":51,\"name\":{\"71\":{},\"155\":{}},\"comment\":{}}],[\"repeateach\",{\"_index\":52,\"name\":{\"72\":{},\"156\":{}},\"comment\":{}}],[\"roadmap\",{\"_index\":94,\"name\":{\"188\":{}},\"comment\":{}}],[\"runningaverage\",{\"_index\":68,\"name\":{\"88\":{},\"172\":{}},\"comment\":{}}],[\"runningpercentile\",{\"_index\":69,\"name\":{\"89\":{},\"173\":{}},\"comment\":{}}],[\"runningreduce\",{\"_index\":53,\"name\":{\"73\":{},\"157\":{}},\"comment\":{}}],[\"runningtotal\",{\"_index\":70,\"name\":{\"90\":{},\"174\":{}},\"comment\":{}}],[\"skip\",{\"_index\":54,\"name\":{\"74\":{},\"158\":{}},\"comment\":{}}],[\"skipwhile\",{\"_index\":55,\"name\":{\"75\":{},\"159\":{}},\"comment\":{}}],[\"some\",{\"_index\":39,\"name\":{\"59\":{},\"143\":{}},\"comment\":{}}],[\"sort\",{\"_index\":56,\"name\":{\"76\":{},\"160\":{}},\"comment\":{}}],[\"split\",{\"_index\":57,\"name\":{\"77\":{},\"161\":{}},\"comment\":{}}],[\"src\",{\"_index\":83,\"name\":{\"108\":{}},\"comment\":{}}],[\"stringtochar\",{\"_index\":73,\"name\":{\"93\":{},\"177\":{}},\"comment\":{}}],[\"syncdoafter\",{\"_index\":14,\"name\":{\"30\":{}},\"comment\":{}}],[\"take\",{\"_index\":58,\"name\":{\"78\":{},\"162\":{}},\"comment\":{}}],[\"takewhile\",{\"_index\":59,\"name\":{\"79\":{},\"163\":{}},\"comment\":{}}],[\"tap\",{\"_index\":60,\"name\":{\"80\":{},\"164\":{}},\"comment\":{}}],[\"then\",{\"_index\":84,\"name\":{\"109\":{}},\"comment\":{}}],[\"thenable\",{\"_index\":9,\"name\":{\"19\":{},\"117\":{}},\"comment\":{}}],[\"thenablefactory\",{\"_index\":10,\"name\":{\"20\":{},\"118\":{}},\"comment\":{}}],[\"throttle\",{\"_index\":76,\"name\":{\"96\":{},\"180\":{}},\"comment\":{}}],[\"tnextfnresult\",{\"_index\":81,\"name\":{\"105\":{}},\"comment\":{}}],[\"total\",{\"_index\":71,\"name\":{\"91\":{},\"175\":{}},\"comment\":{}}],[\"tpushable\",{\"_index\":77,\"name\":{\"97\":{}},\"comment\":{}}],[\"tthenable\",{\"_index\":82,\"name\":{\"106\":{}},\"comment\":{}}],[\"ttransiteratorsyncorasync\",{\"_index\":80,\"name\":{\"103\":{}},\"comment\":{}}],[\"uniq\",{\"_index\":61,\"name\":{\"81\":{},\"165\":{}},\"comment\":{}}],[\"uniqby\",{\"_index\":62,\"name\":{\"82\":{},\"166\":{}},\"comment\":{}}],[\"util\",{\"_index\":2,\"name\":{\"2\":{}},\"comment\":{}}],[\"value\",{\"_index\":85,\"name\":{\"111\":{}},\"comment\":{}}],[\"zip\",{\"_index\":63,\"name\":{\"83\":{},\"167\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file +window.searchData = JSON.parse("{\"kinds\":{\"2\":\"Module\",\"32\":\"Variable\",\"64\":\"Function\",\"1024\":\"Property\",\"65536\":\"Type literal\",\"4194304\":\"Type alias\",\"8388608\":\"Reference\",\"33554432\":\"@knodes/typedoc-plugin-pages: page\"},\"rows\":[{\"kind\":2,\"name\":\"interface\",\"url\":\"modules/interface.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":2,\"name\":\"operators\",\"url\":\"modules/operators.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":2,\"name\":\"util\",\"url\":\"modules/util.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":64,\"name\":\"compose\",\"url\":\"functions/util.compose.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-1.__type-2\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-2.__type-4\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-3.__type-6\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-4.__type-8\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-5.__type-10\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-6.__type-12\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-7.__type-14\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-8.__type-16\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-9.__type-18\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.compose.html#compose-10.__type-20\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.compose.compose\"},{\"kind\":8388608,\"name\":\"itr8Pipe\",\"url\":\"modules/util.html#itr8Pipe\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"pipe\",\"url\":\"functions/util.pipe.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"isPromise\",\"url\":\"functions/util.isPromise.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":32,\"name\":\"AsyncFunction\",\"url\":\"variables/util.AsyncFunction.html\",\"classes\":\"tsd-kind-variable tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"thenable\",\"url\":\"functions/util.thenable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":64,\"name\":\"thenableFactory\",\"url\":\"functions/util.thenableFactory.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.thenableFactory.html#thenableFactory.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.thenableFactory.thenableFactory\"},{\"kind\":64,\"name\":\"doAfter\",\"url\":\"functions/util.doAfter.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfter.html#doAfter.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.doAfter.doAfter\"},{\"kind\":64,\"name\":\"doAfterFactory\",\"url\":\"functions/util.doAfterFactory.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory\"},{\"kind\":1024,\"name\":\"doAfter\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.doAfter\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.doAfter.__type-3\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type.doAfter\"},{\"kind\":1024,\"name\":\"asyncDoAfter\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.asyncDoAfter\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.asyncDoAfter.__type-1\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type.asyncDoAfter\"},{\"kind\":1024,\"name\":\"syncDoAfter\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.syncDoAfter\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/util.doAfterFactory.html#doAfterFactory.__type.syncDoAfter.__type-5\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"util.doAfterFactory.doAfterFactory.__type.syncDoAfter\"},{\"kind\":64,\"name\":\"forLoop\",\"url\":\"functions/util.forLoop.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"util\"},{\"kind\":2,\"name\":\"index\",\"url\":\"modules/index.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":2,\"name\":\"peer\",\"url\":\"modules/peer.html\",\"classes\":\"tsd-kind-module\"},{\"kind\":64,\"name\":\"forEach\",\"url\":\"functions/interface.forEach.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/interface.forEach.html#forEach.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"interface.forEach.forEach\"},{\"kind\":64,\"name\":\"itr8FromArray\",\"url\":\"functions/interface.itr8FromArray.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromArrayAsync\",\"url\":\"functions/interface.itr8FromArrayAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromImpureFunction\",\"url\":\"functions/interface.itr8FromImpureFunction.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromIterable\",\"url\":\"functions/interface.itr8FromIterable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromSingleValue\",\"url\":\"functions/interface.itr8FromSingleValue.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromSingleValueAsync\",\"url\":\"functions/interface.itr8FromSingleValueAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromString\",\"url\":\"functions/interface.itr8FromString.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8FromStringAsync\",\"url\":\"functions/interface.itr8FromStringAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8Interval\",\"url\":\"functions/interface.itr8Interval.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8Pushable\",\"url\":\"functions/interface.itr8Pushable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8Range\",\"url\":\"functions/interface.itr8Range.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8RangeAsync\",\"url\":\"functions/interface.itr8RangeAsync.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToArray\",\"url\":\"functions/interface.itr8ToArray.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToObject\",\"url\":\"functions/interface.itr8ToObject.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToString\",\"url\":\"functions/interface.itr8ToString.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"itr8ToMultiIterable\",\"url\":\"functions/interface.itr8ToMultiIterable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"interface\"},{\"kind\":64,\"name\":\"mostRecent\",\"url\":\"functions/operators.mostRecent.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/operators.mostRecent.html#mostRecent.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"operators.mostRecent.mostRecent\"},{\"kind\":64,\"name\":\"prefetch\",\"url\":\"functions/operators.prefetch.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"functions/operators.prefetch.html#prefetch.__type\",\"classes\":\"tsd-kind-type-literal\",\"parent\":\"operators.prefetch.prefetch\"},{\"kind\":64,\"name\":\"parallel\",\"url\":\"functions/operators.parallel.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"every\",\"url\":\"functions/operators.every.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"some\",\"url\":\"functions/operators.some.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"branchAndMerge\",\"url\":\"functions/operators.branchAndMerge.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"dedup\",\"url\":\"functions/operators.dedup.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"distribute\",\"url\":\"functions/operators.distribute.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"filter\",\"url\":\"functions/operators.filter.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"flatten\",\"url\":\"functions/operators.flatten.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"groupPer\",\"url\":\"functions/operators.groupPer.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"identity\",\"url\":\"functions/operators.identity.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"intersperse\",\"url\":\"functions/operators.intersperse.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"map\",\"url\":\"functions/operators.map.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"peek\",\"url\":\"functions/operators.peek.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"powerMap\",\"url\":\"functions/operators.powerMap.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"reduce\",\"url\":\"functions/operators.reduce.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"repeat\",\"url\":\"functions/operators.repeat.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"repeatEach\",\"url\":\"functions/operators.repeatEach.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningReduce\",\"url\":\"functions/operators.runningReduce.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"skip\",\"url\":\"functions/operators.skip.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"skipWhile\",\"url\":\"functions/operators.skipWhile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"sort\",\"url\":\"functions/operators.sort.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"split\",\"url\":\"functions/operators.split.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"take\",\"url\":\"functions/operators.take.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"takeWhile\",\"url\":\"functions/operators.takeWhile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"tap\",\"url\":\"functions/operators.tap.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"uniq\",\"url\":\"functions/operators.uniq.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"uniqBy\",\"url\":\"functions/operators.uniqBy.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"zip\",\"url\":\"functions/operators.zip.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"average\",\"url\":\"functions/operators.average.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"max\",\"url\":\"functions/operators.max.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"min\",\"url\":\"functions/operators.min.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"percentile\",\"url\":\"functions/operators.percentile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningAverage\",\"url\":\"functions/operators.runningAverage.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningPercentile\",\"url\":\"functions/operators.runningPercentile.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"runningTotal\",\"url\":\"functions/operators.runningTotal.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"total\",\"url\":\"functions/operators.total.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"lineByLine\",\"url\":\"functions/operators.lineByLine.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"stringToChar\",\"url\":\"functions/operators.stringToChar.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"debounce\",\"url\":\"functions/operators.debounce.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"delay\",\"url\":\"functions/operators.delay.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":64,\"name\":\"throttle\",\"url\":\"functions/operators.throttle.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"operators\"},{\"kind\":4194304,\"name\":\"TPushable\",\"url\":\"types/index.TPushable.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TPushable.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"index.TPushable\"},{\"kind\":1024,\"name\":\"push\",\"url\":\"types/index.TPushable.html#__type.push\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TPushable.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TPushable.html#__type.push.__type-3\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"index.TPushable.__type.push\"},{\"kind\":1024,\"name\":\"done\",\"url\":\"types/index.TPushable.html#__type.done\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TPushable.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TPushable.html#__type.done.__type-1\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"index.TPushable.__type.done\"},{\"kind\":4194304,\"name\":\"TTransIteratorSyncOrAsync\",\"url\":\"types/index.TTransIteratorSyncOrAsync.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TTransIteratorSyncOrAsync.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"index.TTransIteratorSyncOrAsync\"},{\"kind\":4194304,\"name\":\"TNextFnResult\",\"url\":\"types/index.TNextFnResult.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":4194304,\"name\":\"TThenable\",\"url\":\"types/index.TThenable.html\",\"classes\":\"tsd-kind-type-alias tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TThenable.html#__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"index.TThenable\"},{\"kind\":1024,\"name\":\"src\",\"url\":\"types/index.TThenable.html#__type.src\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TThenable.__type\"},{\"kind\":1024,\"name\":\"then\",\"url\":\"types/index.TThenable.html#__type.then\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TThenable.__type\"},{\"kind\":65536,\"name\":\"__type\",\"url\":\"types/index.TThenable.html#__type.then.__type-1\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-property\",\"parent\":\"index.TThenable.__type.then\"},{\"kind\":1024,\"name\":\"value\",\"url\":\"types/index.TThenable.html#__type.value\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"index.TThenable.__type\"},{\"kind\":8388608,\"name\":\"compose\",\"url\":\"modules/index.html#compose\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Pipe\",\"url\":\"modules/index.html#itr8Pipe\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"pipe\",\"url\":\"modules/index.html#pipe\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"isPromise\",\"url\":\"modules/index.html#isPromise\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"AsyncFunction\",\"url\":\"modules/index.html#AsyncFunction\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"thenable\",\"url\":\"modules/index.html#thenable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"thenableFactory\",\"url\":\"modules/index.html#thenableFactory\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"doAfter\",\"url\":\"modules/index.html#doAfter\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"doAfterFactory\",\"url\":\"modules/index.html#doAfterFactory\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"forLoop\",\"url\":\"modules/index.html#forLoop\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"forEach\",\"url\":\"modules/index.html#forEach\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromArray\",\"url\":\"modules/index.html#itr8FromArray\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromArrayAsync\",\"url\":\"modules/index.html#itr8FromArrayAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromImpureFunction\",\"url\":\"modules/index.html#itr8FromImpureFunction\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromIterable\",\"url\":\"modules/index.html#itr8FromIterable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromSingleValue\",\"url\":\"modules/index.html#itr8FromSingleValue\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromSingleValueAsync\",\"url\":\"modules/index.html#itr8FromSingleValueAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromString\",\"url\":\"modules/index.html#itr8FromString\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8FromStringAsync\",\"url\":\"modules/index.html#itr8FromStringAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Interval\",\"url\":\"modules/index.html#itr8Interval\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Pushable\",\"url\":\"modules/index.html#itr8Pushable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8Range\",\"url\":\"modules/index.html#itr8Range\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8RangeAsync\",\"url\":\"modules/index.html#itr8RangeAsync\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToArray\",\"url\":\"modules/index.html#itr8ToArray\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToObject\",\"url\":\"modules/index.html#itr8ToObject\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToString\",\"url\":\"modules/index.html#itr8ToString\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"itr8ToMultiIterable\",\"url\":\"modules/index.html#itr8ToMultiIterable\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"mostRecent\",\"url\":\"modules/index.html#mostRecent\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"prefetch\",\"url\":\"modules/index.html#prefetch\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"parallel\",\"url\":\"modules/index.html#parallel\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"every\",\"url\":\"modules/index.html#every\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"some\",\"url\":\"modules/index.html#some\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"branchAndMerge\",\"url\":\"modules/index.html#branchAndMerge\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"dedup\",\"url\":\"modules/index.html#dedup\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"distribute\",\"url\":\"modules/index.html#distribute\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"filter\",\"url\":\"modules/index.html#filter\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"flatten\",\"url\":\"modules/index.html#flatten\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"groupPer\",\"url\":\"modules/index.html#groupPer\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"identity\",\"url\":\"modules/index.html#identity\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"intersperse\",\"url\":\"modules/index.html#intersperse\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"map\",\"url\":\"modules/index.html#map\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"peek\",\"url\":\"modules/index.html#peek\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"powerMap\",\"url\":\"modules/index.html#powerMap\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"reduce\",\"url\":\"modules/index.html#reduce\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"repeat\",\"url\":\"modules/index.html#repeat\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"repeatEach\",\"url\":\"modules/index.html#repeatEach\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningReduce\",\"url\":\"modules/index.html#runningReduce\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"skip\",\"url\":\"modules/index.html#skip\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"skipWhile\",\"url\":\"modules/index.html#skipWhile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"sort\",\"url\":\"modules/index.html#sort\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"split\",\"url\":\"modules/index.html#split\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"take\",\"url\":\"modules/index.html#take\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"takeWhile\",\"url\":\"modules/index.html#takeWhile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"tap\",\"url\":\"modules/index.html#tap\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"uniq\",\"url\":\"modules/index.html#uniq\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"uniqBy\",\"url\":\"modules/index.html#uniqBy\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"zip\",\"url\":\"modules/index.html#zip\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"average\",\"url\":\"modules/index.html#average\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"max\",\"url\":\"modules/index.html#max\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"min\",\"url\":\"modules/index.html#min\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"percentile\",\"url\":\"modules/index.html#percentile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningAverage\",\"url\":\"modules/index.html#runningAverage\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningPercentile\",\"url\":\"modules/index.html#runningPercentile\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"runningTotal\",\"url\":\"modules/index.html#runningTotal\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"total\",\"url\":\"modules/index.html#total\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"lineByLine\",\"url\":\"modules/index.html#lineByLine\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"stringToChar\",\"url\":\"modules/index.html#stringToChar\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"debounce\",\"url\":\"modules/index.html#debounce\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"delay\",\"url\":\"modules/index.html#delay\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":8388608,\"name\":\"throttle\",\"url\":\"modules/index.html#throttle\",\"classes\":\"tsd-kind-reference tsd-parent-kind-module\",\"parent\":\"index\"},{\"kind\":64,\"name\":\"itr8FromStream\",\"url\":\"functions/peer.itr8FromStream.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8ToReadableStream\",\"url\":\"functions/peer.itr8ToReadableStream.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8FromStdin\",\"url\":\"functions/peer.itr8FromStdin.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8FromObservable\",\"url\":\"functions/peer.itr8FromObservable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"itr8ToObservable\",\"url\":\"functions/peer.itr8ToObservable.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":64,\"name\":\"parseJson\",\"url\":\"functions/peer.parseJson.html\",\"classes\":\"tsd-kind-function tsd-parent-kind-module\",\"parent\":\"peer\"},{\"kind\":33554432,\"name\":\"Change Log\",\"url\":\"pages/CHANGELOG.html\",\"classes\":\"pages-entry pages-entry-page\"},{\"kind\":33554432,\"name\":\"Roadmap\",\"url\":\"pages/ROADMAP.html\",\"classes\":\"pages-entry pages-entry-page\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"comment\"],\"fieldVectors\":[[\"name/0\",[0,48.624]],[\"comment/0\",[]],[\"name/1\",[1,48.624]],[\"comment/1\",[]],[\"name/2\",[2,48.624]],[\"comment/2\",[]],[\"name/3\",[3,43.505]],[\"comment/3\",[]],[\"name/4\",[4,19.846]],[\"comment/4\",[]],[\"name/5\",[4,19.846]],[\"comment/5\",[]],[\"name/6\",[4,19.846]],[\"comment/6\",[]],[\"name/7\",[4,19.846]],[\"comment/7\",[]],[\"name/8\",[4,19.846]],[\"comment/8\",[]],[\"name/9\",[4,19.846]],[\"comment/9\",[]],[\"name/10\",[4,19.846]],[\"comment/10\",[]],[\"name/11\",[4,19.846]],[\"comment/11\",[]],[\"name/12\",[4,19.846]],[\"comment/12\",[]],[\"name/13\",[4,19.846]],[\"comment/13\",[]],[\"name/14\",[4,19.846]],[\"comment/14\",[]],[\"name/15\",[5,43.505]],[\"comment/15\",[]],[\"name/16\",[6,43.505]],[\"comment/16\",[]],[\"name/17\",[7,43.505]],[\"comment/17\",[]],[\"name/18\",[8,43.505]],[\"comment/18\",[]],[\"name/19\",[9,43.505]],[\"comment/19\",[]],[\"name/20\",[10,43.505]],[\"comment/20\",[]],[\"name/21\",[4,19.846]],[\"comment/21\",[]],[\"name/22\",[11,40.133]],[\"comment/22\",[]],[\"name/23\",[4,19.846]],[\"comment/23\",[]],[\"name/24\",[12,43.505]],[\"comment/24\",[]],[\"name/25\",[4,19.846]],[\"comment/25\",[]],[\"name/26\",[11,40.133]],[\"comment/26\",[]],[\"name/27\",[4,19.846]],[\"comment/27\",[]],[\"name/28\",[13,48.624]],[\"comment/28\",[]],[\"name/29\",[4,19.846]],[\"comment/29\",[]],[\"name/30\",[14,48.624]],[\"comment/30\",[]],[\"name/31\",[4,19.846]],[\"comment/31\",[]],[\"name/32\",[15,43.505]],[\"comment/32\",[]],[\"name/33\",[16,48.624]],[\"comment/33\",[]],[\"name/34\",[17,48.624]],[\"comment/34\",[]],[\"name/35\",[18,43.505]],[\"comment/35\",[]],[\"name/36\",[4,19.846]],[\"comment/36\",[]],[\"name/37\",[19,43.505]],[\"comment/37\",[]],[\"name/38\",[20,43.505]],[\"comment/38\",[]],[\"name/39\",[21,43.505]],[\"comment/39\",[]],[\"name/40\",[22,43.505]],[\"comment/40\",[]],[\"name/41\",[23,43.505]],[\"comment/41\",[]],[\"name/42\",[24,43.505]],[\"comment/42\",[]],[\"name/43\",[25,43.505]],[\"comment/43\",[]],[\"name/44\",[26,43.505]],[\"comment/44\",[]],[\"name/45\",[27,43.505]],[\"comment/45\",[]],[\"name/46\",[28,43.505]],[\"comment/46\",[]],[\"name/47\",[29,43.505]],[\"comment/47\",[]],[\"name/48\",[30,43.505]],[\"comment/48\",[]],[\"name/49\",[31,43.505]],[\"comment/49\",[]],[\"name/50\",[32,43.505]],[\"comment/50\",[]],[\"name/51\",[33,43.505]],[\"comment/51\",[]],[\"name/52\",[34,43.505]],[\"comment/52\",[]],[\"name/53\",[35,43.505]],[\"comment/53\",[]],[\"name/54\",[4,19.846]],[\"comment/54\",[]],[\"name/55\",[36,43.505]],[\"comment/55\",[]],[\"name/56\",[4,19.846]],[\"comment/56\",[]],[\"name/57\",[37,43.505]],[\"comment/57\",[]],[\"name/58\",[38,43.505]],[\"comment/58\",[]],[\"name/59\",[39,43.505]],[\"comment/59\",[]],[\"name/60\",[40,43.505]],[\"comment/60\",[]],[\"name/61\",[41,43.505]],[\"comment/61\",[]],[\"name/62\",[42,43.505]],[\"comment/62\",[]],[\"name/63\",[43,43.505]],[\"comment/63\",[]],[\"name/64\",[44,43.505]],[\"comment/64\",[]],[\"name/65\",[45,43.505]],[\"comment/65\",[]],[\"name/66\",[46,43.505]],[\"comment/66\",[]],[\"name/67\",[47,43.505]],[\"comment/67\",[]],[\"name/68\",[48,43.505]],[\"comment/68\",[]],[\"name/69\",[49,43.505]],[\"comment/69\",[]],[\"name/70\",[50,43.505]],[\"comment/70\",[]],[\"name/71\",[51,43.505]],[\"comment/71\",[]],[\"name/72\",[52,43.505]],[\"comment/72\",[]],[\"name/73\",[53,43.505]],[\"comment/73\",[]],[\"name/74\",[54,43.505]],[\"comment/74\",[]],[\"name/75\",[55,43.505]],[\"comment/75\",[]],[\"name/76\",[56,43.505]],[\"comment/76\",[]],[\"name/77\",[57,43.505]],[\"comment/77\",[]],[\"name/78\",[58,43.505]],[\"comment/78\",[]],[\"name/79\",[59,43.505]],[\"comment/79\",[]],[\"name/80\",[60,43.505]],[\"comment/80\",[]],[\"name/81\",[61,43.505]],[\"comment/81\",[]],[\"name/82\",[62,43.505]],[\"comment/82\",[]],[\"name/83\",[63,43.505]],[\"comment/83\",[]],[\"name/84\",[64,43.505]],[\"comment/84\",[]],[\"name/85\",[65,43.505]],[\"comment/85\",[]],[\"name/86\",[66,43.505]],[\"comment/86\",[]],[\"name/87\",[67,43.505]],[\"comment/87\",[]],[\"name/88\",[68,43.505]],[\"comment/88\",[]],[\"name/89\",[69,43.505]],[\"comment/89\",[]],[\"name/90\",[70,43.505]],[\"comment/90\",[]],[\"name/91\",[71,43.505]],[\"comment/91\",[]],[\"name/92\",[72,43.505]],[\"comment/92\",[]],[\"name/93\",[73,43.505]],[\"comment/93\",[]],[\"name/94\",[74,43.505]],[\"comment/94\",[]],[\"name/95\",[75,43.505]],[\"comment/95\",[]],[\"name/96\",[76,43.505]],[\"comment/96\",[]],[\"name/97\",[77,43.505]],[\"comment/97\",[]],[\"name/98\",[78,48.624]],[\"comment/98\",[]],[\"name/99\",[4,19.846]],[\"comment/99\",[]],[\"name/100\",[79,48.624]],[\"comment/100\",[]],[\"name/101\",[4,19.846]],[\"comment/101\",[]],[\"name/102\",[80,48.624]],[\"comment/102\",[]],[\"name/103\",[4,19.846]],[\"comment/103\",[]],[\"name/104\",[81,48.624]],[\"comment/104\",[]],[\"name/105\",[4,19.846]],[\"comment/105\",[]],[\"name/106\",[82,48.624]],[\"comment/106\",[]],[\"name/107\",[83,48.624]],[\"comment/107\",[]],[\"name/108\",[4,19.846]],[\"comment/108\",[]],[\"name/109\",[84,48.624]],[\"comment/109\",[]],[\"name/110\",[85,48.624]],[\"comment/110\",[]],[\"name/111\",[4,19.846]],[\"comment/111\",[]],[\"name/112\",[86,48.624]],[\"comment/112\",[]],[\"name/113\",[3,43.505]],[\"comment/113\",[]],[\"name/114\",[5,43.505]],[\"comment/114\",[]],[\"name/115\",[6,43.505]],[\"comment/115\",[]],[\"name/116\",[7,43.505]],[\"comment/116\",[]],[\"name/117\",[8,43.505]],[\"comment/117\",[]],[\"name/118\",[9,43.505]],[\"comment/118\",[]],[\"name/119\",[10,43.505]],[\"comment/119\",[]],[\"name/120\",[11,40.133]],[\"comment/120\",[]],[\"name/121\",[12,43.505]],[\"comment/121\",[]],[\"name/122\",[15,43.505]],[\"comment/122\",[]],[\"name/123\",[18,43.505]],[\"comment/123\",[]],[\"name/124\",[19,43.505]],[\"comment/124\",[]],[\"name/125\",[20,43.505]],[\"comment/125\",[]],[\"name/126\",[21,43.505]],[\"comment/126\",[]],[\"name/127\",[22,43.505]],[\"comment/127\",[]],[\"name/128\",[23,43.505]],[\"comment/128\",[]],[\"name/129\",[24,43.505]],[\"comment/129\",[]],[\"name/130\",[25,43.505]],[\"comment/130\",[]],[\"name/131\",[26,43.505]],[\"comment/131\",[]],[\"name/132\",[27,43.505]],[\"comment/132\",[]],[\"name/133\",[28,43.505]],[\"comment/133\",[]],[\"name/134\",[29,43.505]],[\"comment/134\",[]],[\"name/135\",[30,43.505]],[\"comment/135\",[]],[\"name/136\",[31,43.505]],[\"comment/136\",[]],[\"name/137\",[32,43.505]],[\"comment/137\",[]],[\"name/138\",[33,43.505]],[\"comment/138\",[]],[\"name/139\",[34,43.505]],[\"comment/139\",[]],[\"name/140\",[35,43.505]],[\"comment/140\",[]],[\"name/141\",[36,43.505]],[\"comment/141\",[]],[\"name/142\",[37,43.505]],[\"comment/142\",[]],[\"name/143\",[38,43.505]],[\"comment/143\",[]],[\"name/144\",[39,43.505]],[\"comment/144\",[]],[\"name/145\",[40,43.505]],[\"comment/145\",[]],[\"name/146\",[41,43.505]],[\"comment/146\",[]],[\"name/147\",[42,43.505]],[\"comment/147\",[]],[\"name/148\",[43,43.505]],[\"comment/148\",[]],[\"name/149\",[44,43.505]],[\"comment/149\",[]],[\"name/150\",[45,43.505]],[\"comment/150\",[]],[\"name/151\",[46,43.505]],[\"comment/151\",[]],[\"name/152\",[47,43.505]],[\"comment/152\",[]],[\"name/153\",[48,43.505]],[\"comment/153\",[]],[\"name/154\",[49,43.505]],[\"comment/154\",[]],[\"name/155\",[50,43.505]],[\"comment/155\",[]],[\"name/156\",[51,43.505]],[\"comment/156\",[]],[\"name/157\",[52,43.505]],[\"comment/157\",[]],[\"name/158\",[53,43.505]],[\"comment/158\",[]],[\"name/159\",[54,43.505]],[\"comment/159\",[]],[\"name/160\",[55,43.505]],[\"comment/160\",[]],[\"name/161\",[56,43.505]],[\"comment/161\",[]],[\"name/162\",[57,43.505]],[\"comment/162\",[]],[\"name/163\",[58,43.505]],[\"comment/163\",[]],[\"name/164\",[59,43.505]],[\"comment/164\",[]],[\"name/165\",[60,43.505]],[\"comment/165\",[]],[\"name/166\",[61,43.505]],[\"comment/166\",[]],[\"name/167\",[62,43.505]],[\"comment/167\",[]],[\"name/168\",[63,43.505]],[\"comment/168\",[]],[\"name/169\",[64,43.505]],[\"comment/169\",[]],[\"name/170\",[65,43.505]],[\"comment/170\",[]],[\"name/171\",[66,43.505]],[\"comment/171\",[]],[\"name/172\",[67,43.505]],[\"comment/172\",[]],[\"name/173\",[68,43.505]],[\"comment/173\",[]],[\"name/174\",[69,43.505]],[\"comment/174\",[]],[\"name/175\",[70,43.505]],[\"comment/175\",[]],[\"name/176\",[71,43.505]],[\"comment/176\",[]],[\"name/177\",[72,43.505]],[\"comment/177\",[]],[\"name/178\",[73,43.505]],[\"comment/178\",[]],[\"name/179\",[74,43.505]],[\"comment/179\",[]],[\"name/180\",[75,43.505]],[\"comment/180\",[]],[\"name/181\",[76,43.505]],[\"comment/181\",[]],[\"name/182\",[77,43.505]],[\"comment/182\",[]],[\"name/183\",[87,48.624]],[\"comment/183\",[]],[\"name/184\",[88,48.624]],[\"comment/184\",[]],[\"name/185\",[89,48.624]],[\"comment/185\",[]],[\"name/186\",[90,48.624]],[\"comment/186\",[]],[\"name/187\",[91,48.624]],[\"comment/187\",[]],[\"name/188\",[92,48.624]],[\"comment/188\",[]],[\"name/189\",[93,34.538,94,34.538]],[\"comment/189\",[]],[\"name/190\",[95,48.624]],[\"comment/190\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":4,\"name\":{\"4\":{},\"5\":{},\"6\":{},\"7\":{},\"8\":{},\"9\":{},\"10\":{},\"11\":{},\"12\":{},\"13\":{},\"14\":{},\"21\":{},\"23\":{},\"25\":{},\"27\":{},\"29\":{},\"31\":{},\"36\":{},\"54\":{},\"56\":{},\"99\":{},\"101\":{},\"103\":{},\"105\":{},\"108\":{},\"111\":{}},\"comment\":{}}],[\"asyncdoafter\",{\"_index\":13,\"name\":{\"28\":{}},\"comment\":{}}],[\"asyncfunction\",{\"_index\":8,\"name\":{\"18\":{},\"117\":{}},\"comment\":{}}],[\"average\",{\"_index\":65,\"name\":{\"85\":{},\"170\":{}},\"comment\":{}}],[\"branchandmerge\",{\"_index\":40,\"name\":{\"60\":{},\"145\":{}},\"comment\":{}}],[\"change\",{\"_index\":93,\"name\":{\"189\":{}},\"comment\":{}}],[\"compose\",{\"_index\":3,\"name\":{\"3\":{},\"113\":{}},\"comment\":{}}],[\"debounce\",{\"_index\":75,\"name\":{\"95\":{},\"180\":{}},\"comment\":{}}],[\"dedup\",{\"_index\":41,\"name\":{\"61\":{},\"146\":{}},\"comment\":{}}],[\"delay\",{\"_index\":76,\"name\":{\"96\":{},\"181\":{}},\"comment\":{}}],[\"distribute\",{\"_index\":42,\"name\":{\"62\":{},\"147\":{}},\"comment\":{}}],[\"doafter\",{\"_index\":11,\"name\":{\"22\":{},\"26\":{},\"120\":{}},\"comment\":{}}],[\"doafterfactory\",{\"_index\":12,\"name\":{\"24\":{},\"121\":{}},\"comment\":{}}],[\"done\",{\"_index\":80,\"name\":{\"102\":{}},\"comment\":{}}],[\"every\",{\"_index\":38,\"name\":{\"58\":{},\"143\":{}},\"comment\":{}}],[\"filter\",{\"_index\":43,\"name\":{\"63\":{},\"148\":{}},\"comment\":{}}],[\"flatten\",{\"_index\":44,\"name\":{\"64\":{},\"149\":{}},\"comment\":{}}],[\"foreach\",{\"_index\":18,\"name\":{\"35\":{},\"123\":{}},\"comment\":{}}],[\"forloop\",{\"_index\":15,\"name\":{\"32\":{},\"122\":{}},\"comment\":{}}],[\"groupper\",{\"_index\":45,\"name\":{\"65\":{},\"150\":{}},\"comment\":{}}],[\"identity\",{\"_index\":46,\"name\":{\"66\":{},\"151\":{}},\"comment\":{}}],[\"index\",{\"_index\":16,\"name\":{\"33\":{}},\"comment\":{}}],[\"interface\",{\"_index\":0,\"name\":{\"0\":{}},\"comment\":{}}],[\"intersperse\",{\"_index\":47,\"name\":{\"67\":{},\"152\":{}},\"comment\":{}}],[\"ispromise\",{\"_index\":7,\"name\":{\"17\":{},\"116\":{}},\"comment\":{}}],[\"itr8fromarray\",{\"_index\":19,\"name\":{\"37\":{},\"124\":{}},\"comment\":{}}],[\"itr8fromarrayasync\",{\"_index\":20,\"name\":{\"38\":{},\"125\":{}},\"comment\":{}}],[\"itr8fromimpurefunction\",{\"_index\":21,\"name\":{\"39\":{},\"126\":{}},\"comment\":{}}],[\"itr8fromiterable\",{\"_index\":22,\"name\":{\"40\":{},\"127\":{}},\"comment\":{}}],[\"itr8fromobservable\",{\"_index\":90,\"name\":{\"186\":{}},\"comment\":{}}],[\"itr8fromsinglevalue\",{\"_index\":23,\"name\":{\"41\":{},\"128\":{}},\"comment\":{}}],[\"itr8fromsinglevalueasync\",{\"_index\":24,\"name\":{\"42\":{},\"129\":{}},\"comment\":{}}],[\"itr8fromstdin\",{\"_index\":89,\"name\":{\"185\":{}},\"comment\":{}}],[\"itr8fromstream\",{\"_index\":87,\"name\":{\"183\":{}},\"comment\":{}}],[\"itr8fromstring\",{\"_index\":25,\"name\":{\"43\":{},\"130\":{}},\"comment\":{}}],[\"itr8fromstringasync\",{\"_index\":26,\"name\":{\"44\":{},\"131\":{}},\"comment\":{}}],[\"itr8interval\",{\"_index\":27,\"name\":{\"45\":{},\"132\":{}},\"comment\":{}}],[\"itr8pipe\",{\"_index\":5,\"name\":{\"15\":{},\"114\":{}},\"comment\":{}}],[\"itr8pushable\",{\"_index\":28,\"name\":{\"46\":{},\"133\":{}},\"comment\":{}}],[\"itr8range\",{\"_index\":29,\"name\":{\"47\":{},\"134\":{}},\"comment\":{}}],[\"itr8rangeasync\",{\"_index\":30,\"name\":{\"48\":{},\"135\":{}},\"comment\":{}}],[\"itr8toarray\",{\"_index\":31,\"name\":{\"49\":{},\"136\":{}},\"comment\":{}}],[\"itr8tomultiiterable\",{\"_index\":34,\"name\":{\"52\":{},\"139\":{}},\"comment\":{}}],[\"itr8toobject\",{\"_index\":32,\"name\":{\"50\":{},\"137\":{}},\"comment\":{}}],[\"itr8toobservable\",{\"_index\":91,\"name\":{\"187\":{}},\"comment\":{}}],[\"itr8toreadablestream\",{\"_index\":88,\"name\":{\"184\":{}},\"comment\":{}}],[\"itr8tostring\",{\"_index\":33,\"name\":{\"51\":{},\"138\":{}},\"comment\":{}}],[\"linebyline\",{\"_index\":73,\"name\":{\"93\":{},\"178\":{}},\"comment\":{}}],[\"log\",{\"_index\":94,\"name\":{\"189\":{}},\"comment\":{}}],[\"map\",{\"_index\":48,\"name\":{\"68\":{},\"153\":{}},\"comment\":{}}],[\"max\",{\"_index\":66,\"name\":{\"86\":{},\"171\":{}},\"comment\":{}}],[\"min\",{\"_index\":67,\"name\":{\"87\":{},\"172\":{}},\"comment\":{}}],[\"mostrecent\",{\"_index\":35,\"name\":{\"53\":{},\"140\":{}},\"comment\":{}}],[\"operators\",{\"_index\":1,\"name\":{\"1\":{}},\"comment\":{}}],[\"parallel\",{\"_index\":37,\"name\":{\"57\":{},\"142\":{}},\"comment\":{}}],[\"parsejson\",{\"_index\":92,\"name\":{\"188\":{}},\"comment\":{}}],[\"peek\",{\"_index\":49,\"name\":{\"69\":{},\"154\":{}},\"comment\":{}}],[\"peer\",{\"_index\":17,\"name\":{\"34\":{}},\"comment\":{}}],[\"percentile\",{\"_index\":68,\"name\":{\"88\":{},\"173\":{}},\"comment\":{}}],[\"pipe\",{\"_index\":6,\"name\":{\"16\":{},\"115\":{}},\"comment\":{}}],[\"powermap\",{\"_index\":50,\"name\":{\"70\":{},\"155\":{}},\"comment\":{}}],[\"prefetch\",{\"_index\":36,\"name\":{\"55\":{},\"141\":{}},\"comment\":{}}],[\"push\",{\"_index\":79,\"name\":{\"100\":{}},\"comment\":{}}],[\"reduce\",{\"_index\":51,\"name\":{\"71\":{},\"156\":{}},\"comment\":{}}],[\"repeat\",{\"_index\":52,\"name\":{\"72\":{},\"157\":{}},\"comment\":{}}],[\"repeateach\",{\"_index\":53,\"name\":{\"73\":{},\"158\":{}},\"comment\":{}}],[\"roadmap\",{\"_index\":95,\"name\":{\"190\":{}},\"comment\":{}}],[\"runningaverage\",{\"_index\":69,\"name\":{\"89\":{},\"174\":{}},\"comment\":{}}],[\"runningpercentile\",{\"_index\":70,\"name\":{\"90\":{},\"175\":{}},\"comment\":{}}],[\"runningreduce\",{\"_index\":54,\"name\":{\"74\":{},\"159\":{}},\"comment\":{}}],[\"runningtotal\",{\"_index\":71,\"name\":{\"91\":{},\"176\":{}},\"comment\":{}}],[\"skip\",{\"_index\":55,\"name\":{\"75\":{},\"160\":{}},\"comment\":{}}],[\"skipwhile\",{\"_index\":56,\"name\":{\"76\":{},\"161\":{}},\"comment\":{}}],[\"some\",{\"_index\":39,\"name\":{\"59\":{},\"144\":{}},\"comment\":{}}],[\"sort\",{\"_index\":57,\"name\":{\"77\":{},\"162\":{}},\"comment\":{}}],[\"split\",{\"_index\":58,\"name\":{\"78\":{},\"163\":{}},\"comment\":{}}],[\"src\",{\"_index\":84,\"name\":{\"109\":{}},\"comment\":{}}],[\"stringtochar\",{\"_index\":74,\"name\":{\"94\":{},\"179\":{}},\"comment\":{}}],[\"syncdoafter\",{\"_index\":14,\"name\":{\"30\":{}},\"comment\":{}}],[\"take\",{\"_index\":59,\"name\":{\"79\":{},\"164\":{}},\"comment\":{}}],[\"takewhile\",{\"_index\":60,\"name\":{\"80\":{},\"165\":{}},\"comment\":{}}],[\"tap\",{\"_index\":61,\"name\":{\"81\":{},\"166\":{}},\"comment\":{}}],[\"then\",{\"_index\":85,\"name\":{\"110\":{}},\"comment\":{}}],[\"thenable\",{\"_index\":9,\"name\":{\"19\":{},\"118\":{}},\"comment\":{}}],[\"thenablefactory\",{\"_index\":10,\"name\":{\"20\":{},\"119\":{}},\"comment\":{}}],[\"throttle\",{\"_index\":77,\"name\":{\"97\":{},\"182\":{}},\"comment\":{}}],[\"tnextfnresult\",{\"_index\":82,\"name\":{\"106\":{}},\"comment\":{}}],[\"total\",{\"_index\":72,\"name\":{\"92\":{},\"177\":{}},\"comment\":{}}],[\"tpushable\",{\"_index\":78,\"name\":{\"98\":{}},\"comment\":{}}],[\"tthenable\",{\"_index\":83,\"name\":{\"107\":{}},\"comment\":{}}],[\"ttransiteratorsyncorasync\",{\"_index\":81,\"name\":{\"104\":{}},\"comment\":{}}],[\"uniq\",{\"_index\":62,\"name\":{\"82\":{},\"167\":{}},\"comment\":{}}],[\"uniqby\",{\"_index\":63,\"name\":{\"83\":{},\"168\":{}},\"comment\":{}}],[\"util\",{\"_index\":2,\"name\":{\"2\":{}},\"comment\":{}}],[\"value\",{\"_index\":86,\"name\":{\"112\":{}},\"comment\":{}}],[\"zip\",{\"_index\":64,\"name\":{\"84\":{},\"169\":{}},\"comment\":{}}]],\"pipeline\":[]}}"); \ No newline at end of file diff --git a/docs/functions/interface.forEach.html b/docs/functions/interface.forEach.html index 106044c..dcf0d8b 100644 --- a/docs/functions/interface.forEach.html +++ b/docs/functions/interface.forEach.html @@ -72,7 +72,7 @@

Parameters

it: Iterator<T, any, undefined> | AsyncIterator<T, any, undefined>

Returns void | Promise<void>

+
  • Defined in interface/forEach.ts:30
  • Returns IterableIterator<T>

    +
  • Defined in interface/itr8FromArray.ts:11
  • Returns AsyncIterableIterator<T>

    +
  • Defined in interface/itr8FromArrayAsync.ts:9
  • +
  • Defined in interface/itr8FromImpureFunction.ts:23
  • +
  • Defined in interface/itr8FromIterable.ts:15
  • +
  • Defined in interface/itr8FromSingleValue.ts:10
  • +
  • Defined in interface/itr8FromSingleValueAsync.ts:10
  • Returns IterableIterator<string>

    +
  • Defined in interface/itr8FromString.ts:13
  • Returns AsyncIterableIterator<string>

    +
  • Defined in interface/itr8FromStringAsync.ts:10
  • +
  • Defined in interface/itr8Interval.ts:16
  • +
  • Defined in interface/itr8Pushable.ts:19
  • +
  • Defined in interface/itr8Range.ts:33
  • +
  • Defined in interface/itr8RangeAsync.ts:16
  • +
  • Defined in interface/itr8ToArray.ts:11
  • +
  • Defined in interface/itr8ToMultiIterable.ts:28
  • +
  • Defined in interface/itr8ToObject.ts:36
  • +
  • Defined in interface/itr8ToString.ts:31
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C]>

    +
  • Defined in operators/general/branchAndMerge.ts:71
  • @@ -93,7 +93,7 @@
    transIt2: TTransIteratorSyncOrAsync<C, D>
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C, D]>

    +
  • Defined in operators/general/branchAndMerge.ts:75
  • @@ -122,7 +122,7 @@
    transIt3: TTransIteratorSyncOrAsync<D, E>
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C, D, E]>

    +
  • Defined in operators/general/branchAndMerge.ts:80
  • @@ -155,7 +155,7 @@
    transIt4: TTransIteratorSyncOrAsync<E, F>
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C, D, E, F]>

    +
  • Defined in operators/general/branchAndMerge.ts:86
  • @@ -192,7 +192,7 @@
    transIt5: TTransIteratorSyncOrAsync<F, G>
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C, D, E, F, G]>

    +
  • Defined in operators/general/branchAndMerge.ts:93
  • @@ -233,7 +233,7 @@
    transIt6: TTransIteratorSyncOrAsync<G, H>
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C, D, E, F, G, H]>

    +
  • Defined in operators/general/branchAndMerge.ts:101
  • @@ -278,7 +278,7 @@
    transIt7: TTransIteratorSyncOrAsync<H, I>
  • Returns TTransIteratorSyncOrAsync<A, [A, B, C, D, E, F, G, H, I]>

    +
  • Defined in operators/general/branchAndMerge.ts:110
  • +
  • Defined in operators/timeBased/debounce.ts:46
  • +
  • Defined in operators/general/dedup.ts:32
  • +
  • Defined in operators/timeBased/delay.ts:9
  • Returns TTransIteratorSyncOrAsync<TIn, boolean>

    +
  • Defined in operators/boolean/every.ts:20
  • +
  • Defined in operators/general/filter.ts:13
  • +
  • Defined in operators/general/groupPer.ts:15
  • +
  • Defined in operators/general/intersperse.ts:22
  • +
  • Defined in operators/strings/lineByLine.ts:32
  • +
  • Defined in operators/general/map.ts:16
  • +
  • Defined in operators/async/mostRecent.ts:59
  • Returns TTransIteratorSyncOrAsync<A, C>

    +
  • Defined in operators/async/parallel.ts:85
  • @@ -123,7 +123,7 @@
    transIt2: TTransIteratorSyncOrAsync<C, D>
  • Returns TTransIteratorSyncOrAsync<A, D>

    +
  • Defined in operators/async/parallel.ts:90
  • @@ -159,7 +159,7 @@
    transIt3: TTransIteratorSyncOrAsync<D, E>
  • Returns TTransIteratorSyncOrAsync<A, E>

    +
  • Defined in operators/async/parallel.ts:96
  • @@ -199,7 +199,7 @@
    transIt4: TTransIteratorSyncOrAsync<E, F>
  • Returns TTransIteratorSyncOrAsync<A, F>

    +
  • Defined in operators/async/parallel.ts:103
  • +
  • Defined in operators/general/peek.ts:115
  • +
  • Defined in operators/numeric/percentile.ts:25
  • +
  • Defined in operators/general/powerMap.ts:950
  • +
  • Defined in operators/async/prefetch.ts:30
  • +
  • Defined in operators/general/reduce.ts:27
  • +
  • Defined in operators/general/repeat.ts:37
  • +
  • Defined in operators/general/repeatEach.ts:34
  • +
  • Defined in operators/numeric/runningPercentile.ts:17
  • +
  • Defined in operators/general/runningReduce.ts:27
  • +
  • Defined in operators/general/skip.ts:10
  • +
  • Defined in operators/general/skipWhile.ts:20
  • Returns TTransIteratorSyncOrAsync<TIn, boolean>

    +
  • Defined in operators/boolean/some.ts:20
  • +
  • Defined in operators/general/sort.ts:26
  • +
  • Defined in operators/general/split.ts:22
  • +
  • Defined in operators/general/take.ts:13
  • +
  • Defined in operators/general/takeWhile.ts:12
  • Returns void

    Returns TTransIteratorSyncOrAsync<TIn, TIn>

    +
  • Defined in operators/general/tap.ts:11
  • +
  • Defined in operators/timeBased/throttle.ts:46
  • +
  • Defined in operators/general/uniqBy.ts:21
  • +
  • Defined in operators/general/zip.ts:22
  • +
  • Defined in peer/observable.ts:13
  • +
  • Defined in peer/stream.ts:93
  • +
  • Defined in peer/stream.ts:29
  • +
  • Defined in peer/observable.ts:86
  • +
  • Defined in peer/stream.ts:111
  • +
  • Defined in peer/parseJson.ts:38
  • Returns C

    +
  • Defined in util/index.ts:480
  • @@ -190,7 +190,7 @@

    Parameters

    x: A
  • Returns D

    +
  • Defined in util/index.ts:481
  • @@ -274,7 +274,7 @@

    Parameters

    x: A
  • Returns E

    +
  • Defined in util/index.ts:486
  • @@ -373,7 +373,7 @@

    Parameters

    x: A
  • Returns F

    +
  • Defined in util/index.ts:492
  • @@ -487,7 +487,7 @@

    Parameters

    x: A
  • Returns G

    +
  • Defined in util/index.ts:499
  • @@ -616,7 +616,7 @@

    Parameters

    x: A
  • Returns H

    +
  • Defined in util/index.ts:507
  • @@ -760,7 +760,7 @@

    Parameters

    x: A
  • Returns I

    +
  • Defined in util/index.ts:516
  • @@ -919,7 +919,7 @@

    Parameters

    x: A
  • Returns J

    +
  • Defined in util/index.ts:526
  • @@ -1093,7 +1093,7 @@

    Parameters

    x: A
  • Returns K

    +
  • Defined in util/index.ts:537
  • @@ -1269,7 +1269,7 @@

    Parameters

    x: A
  • Returns unknown

    +
  • Defined in util/index.ts:549
  • +
  • Defined in util/index.ts:269
  • +
  • Defined in util/index.ts:300
  • +
  • Defined in util/index.ts:344
  • +
  • Defined in util/index.ts:23
  • Returns B

    +
  • Defined in util/index.ts:589
  • @@ -159,7 +159,7 @@
    x: B<

    Returns C

  • Returns C

    +
  • Defined in util/index.ts:590
  • @@ -234,7 +234,7 @@
    x: C<

    Returns D

  • Returns D

    +
  • Defined in util/index.ts:596
  • @@ -324,7 +324,7 @@
    x: D<

    Returns E

  • Returns E

    +
  • Defined in util/index.ts:603
  • @@ -429,7 +429,7 @@
    x: E<

    Returns F

  • Returns F

    +
  • Defined in util/index.ts:611
  • @@ -549,7 +549,7 @@
    x: F<

    Returns G

  • Returns G

    +
  • Defined in util/index.ts:620
  • @@ -684,7 +684,7 @@
    x: G<

    Returns H

  • Returns H

    +
  • Defined in util/index.ts:630
  • @@ -834,7 +834,7 @@
    x: H<

    Returns I

  • Returns I

    +
  • Defined in util/index.ts:641
  • @@ -999,7 +999,7 @@
    x: I<

    Returns J

  • Returns J

    +
  • Defined in util/index.ts:653
  • @@ -1166,7 +1166,7 @@

    Returns Rest ...moreFns: ((x: unknown) => unknown)[]

  • Returns unknown

    +
  • Defined in util/index.ts:666
  • Returns TThenable<T>

    +
  • Defined in util/index.ts:101
  • +
  • Defined in util/index.ts:164
  • +
  • Defined in interface/index.ts:36
  • diff --git a/docs/modules/operators.html b/docs/modules/operators.html index 4ce45e1..45a37c4 100644 --- a/docs/modules/operators.html +++ b/docs/modules/operators.html @@ -31,7 +31,7 @@

    Example

    import {
     
    +
  • Defined in operators/index.ts:26
  • @@ -43,8 +43,7 @@

    Functions - Other

    Functions - operators/async

    -
    branchAndMerge -identity +
    identity mostRecent parallel prefetch @@ -56,7 +55,9 @@

    Functions - operators/boolean

    Functions - operators/general

    -
    dedup +
    branchAndMerge +dedup +distribute filter flatten groupPer @@ -135,6 +136,7 @@

    debounce
  • dedup
  • delay
  • +
  • distribute
  • every
  • filter
  • flatten
  • diff --git a/docs/modules/peer.html b/docs/modules/peer.html index 29d2ac6..dfd586c 100644 --- a/docs/modules/peer.html +++ b/docs/modules/peer.html @@ -26,7 +26,7 @@

    Module peer

    +
  • Defined in peer/index.ts:17
  • diff --git a/docs/modules/util.html b/docs/modules/util.html index 6f2dc4c..e9cefa0 100644 --- a/docs/modules/util.html +++ b/docs/modules/util.html @@ -21,7 +21,7 @@

    Module util

    (by using thenable, forLoop or isPromise).

    +
  • Defined in util/index.ts:11
  • diff --git a/docs/pages/CHANGELOG.html b/docs/pages/CHANGELOG.html index bec3bde..c43d0dd 100644 --- a/docs/pages/CHANGELOG.html +++ b/docs/pages/CHANGELOG.html @@ -57,11 +57,39 @@

    Fixed

    Security

    + +

    version 0.4.9 (2024-08-27)

    +
    + + +

    Added

    +
    +
      +
    • distribute operator: taking [categroy, value] tuples as input, it will send +values to sub-iterator branches based on category
    • +
    • for itr8 developers:
        +
      • package.json:scripts.release added read OTP for npm publishing +and then pass it to npm publish command (--otp $OTP)
      • +
      • added c8 to npm test script to check code-coverage of the tests
      • +
      • added missing async iterator tests for itr8ToString
      • +
      • added 'npm run benchmark'
      • +
      +
    • +
    + + +

    Fixed

    +
    +
      +
    • typing issue on tap operator
    • +
    • updated micromatch to fix a Regular Expression Denial of Service (ReDoS)
    • +
    +

    version 0.4.8 (2024-08-08)

    - +

    Added

      @@ -88,7 +116,7 @@

      Changed

      version 0.4.7 (2024-07-13)

      - +

      Added

        diff --git a/docs/sitemap.txt b/docs/sitemap.txt index e6956b5..aa92b2e 100644 --- a/docs/sitemap.txt +++ b/docs/sitemap.txt @@ -1,87 +1,88 @@ -https://mrft.github.io/itr8/functions/operators.tap.html -https://mrft.github.io/itr8/functions/operators.split.html -https://mrft.github.io/itr8/functions/operators.min.html -https://mrft.github.io/itr8/functions/interface.itr8ToString.html -https://mrft.github.io/itr8/functions/operators.uniq.html -https://mrft.github.io/itr8/functions/interface.itr8FromArray.html -https://mrft.github.io/itr8/functions/interface.itr8Interval.html -https://mrft.github.io/itr8/functions/interface.itr8Pushable.html +https://mrft.github.io/itr8/functions/util.forLoop.html +https://mrft.github.io/itr8/functions/operators.map.html +https://mrft.github.io/itr8/functions/operators.throttle.html +https://mrft.github.io/itr8/functions/util.thenable.html +https://mrft.github.io/itr8/functions/operators.stringToChar.html +https://mrft.github.io/itr8/functions/operators.peek.html +https://mrft.github.io/itr8/functions/operators.total.html +https://mrft.github.io/itr8/functions/operators.percentile.html https://mrft.github.io/itr8/functions/peer.itr8ToObservable.html -https://mrft.github.io/itr8/functions/operators.average.html -https://mrft.github.io/itr8/functions/operators.some.html -https://mrft.github.io/itr8/functions/operators.take.html -https://mrft.github.io/itr8/functions/peer.parseJson.html -https://mrft.github.io/itr8/functions/interface.itr8FromImpureFunction.html -https://mrft.github.io/itr8/functions/operators.max.html -https://mrft.github.io/itr8/functions/operators.groupPer.html +https://mrft.github.io/itr8/functions/operators.tap.html +https://mrft.github.io/itr8/functions/operators.lineByLine.html +https://mrft.github.io/itr8/functions/operators.identity.html +https://mrft.github.io/itr8/functions/operators.sort.html https://mrft.github.io/itr8/functions/operators.dedup.html -https://mrft.github.io/itr8/functions/operators.delay.html -https://mrft.github.io/itr8/functions/operators.runningAverage.html -https://mrft.github.io/itr8/functions/util.thenableFactory.html +https://mrft.github.io/itr8/functions/interface.itr8FromString.html https://mrft.github.io/itr8/functions/operators.prefetch.html -https://mrft.github.io/itr8/functions/operators.runningPercentile.html -https://mrft.github.io/itr8/functions/operators.percentile.html -https://mrft.github.io/itr8/functions/operators.repeat.html -https://mrft.github.io/itr8/functions/operators.uniqBy.html +https://mrft.github.io/itr8/functions/peer.itr8FromStdin.html +https://mrft.github.io/itr8/functions/interface.itr8FromSingleValue.html +https://mrft.github.io/itr8/functions/operators.runningTotal.html +https://mrft.github.io/itr8/functions/interface.itr8ToArray.html https://mrft.github.io/itr8/functions/operators.branchAndMerge.html -https://mrft.github.io/itr8/functions/util.doAfterFactory.html -https://mrft.github.io/itr8/functions/util.isPromise.html -https://mrft.github.io/itr8/functions/util.compose.html -https://mrft.github.io/itr8/functions/peer.itr8FromObservable.html -https://mrft.github.io/itr8/functions/operators.flatten.html -https://mrft.github.io/itr8/functions/operators.peek.html -https://mrft.github.io/itr8/functions/operators.lineByLine.html -https://mrft.github.io/itr8/functions/interface.itr8FromArrayAsync.html -https://mrft.github.io/itr8/functions/operators.reduce.html +https://mrft.github.io/itr8/functions/operators.uniqBy.html +https://mrft.github.io/itr8/functions/interface.itr8Pushable.html +https://mrft.github.io/itr8/functions/interface.itr8FromImpureFunction.html +https://mrft.github.io/itr8/functions/operators.delay.html +https://mrft.github.io/itr8/functions/operators.min.html https://mrft.github.io/itr8/functions/operators.filter.html https://mrft.github.io/itr8/functions/interface.itr8ToMultiIterable.html -https://mrft.github.io/itr8/functions/interface.itr8FromSingleValue.html -https://mrft.github.io/itr8/functions/interface.itr8FromStringAsync.html -https://mrft.github.io/itr8/functions/operators.zip.html -https://mrft.github.io/itr8/functions/interface.itr8RangeAsync.html -https://mrft.github.io/itr8/functions/interface.itr8FromString.html -https://mrft.github.io/itr8/functions/util.pipe.html +https://mrft.github.io/itr8/functions/interface.itr8FromArray.html +https://mrft.github.io/itr8/functions/operators.reduce.html +https://mrft.github.io/itr8/functions/operators.parallel.html +https://mrft.github.io/itr8/functions/peer.itr8ToReadableStream.html +https://mrft.github.io/itr8/functions/interface.itr8ToString.html +https://mrft.github.io/itr8/functions/operators.uniq.html +https://mrft.github.io/itr8/functions/operators.repeat.html +https://mrft.github.io/itr8/functions/operators.takeWhile.html +https://mrft.github.io/itr8/functions/peer.parseJson.html +https://mrft.github.io/itr8/functions/peer.itr8FromStream.html https://mrft.github.io/itr8/functions/operators.every.html -https://mrft.github.io/itr8/functions/interface.itr8FromSingleValueAsync.html +https://mrft.github.io/itr8/functions/operators.powerMap.html +https://mrft.github.io/itr8/functions/operators.take.html +https://mrft.github.io/itr8/functions/interface.itr8ToObject.html +https://mrft.github.io/itr8/functions/interface.itr8FromArrayAsync.html +https://mrft.github.io/itr8/functions/operators.flatten.html https://mrft.github.io/itr8/functions/operators.skip.html -https://mrft.github.io/itr8/functions/operators.identity.html -https://mrft.github.io/itr8/functions/operators.runningReduce.html -https://mrft.github.io/itr8/functions/operators.takeWhile.html -https://mrft.github.io/itr8/functions/util.thenable.html +https://mrft.github.io/itr8/functions/operators.runningPercentile.html +https://mrft.github.io/itr8/functions/interface.itr8FromSingleValueAsync.html https://mrft.github.io/itr8/functions/util.doAfter.html -https://mrft.github.io/itr8/functions/operators.runningTotal.html -https://mrft.github.io/itr8/functions/peer.itr8FromStdin.html -https://mrft.github.io/itr8/functions/util.forLoop.html -https://mrft.github.io/itr8/functions/interface.itr8ToArray.html -https://mrft.github.io/itr8/functions/peer.itr8ToReadableStream.html -https://mrft.github.io/itr8/functions/operators.throttle.html -https://mrft.github.io/itr8/functions/interface.forEach.html -https://mrft.github.io/itr8/functions/operators.parallel.html -https://mrft.github.io/itr8/functions/operators.sort.html -https://mrft.github.io/itr8/functions/operators.map.html -https://mrft.github.io/itr8/functions/interface.itr8ToObject.html -https://mrft.github.io/itr8/functions/operators.debounce.html -https://mrft.github.io/itr8/functions/operators.total.html -https://mrft.github.io/itr8/functions/operators.powerMap.html -https://mrft.github.io/itr8/functions/operators.mostRecent.html +https://mrft.github.io/itr8/functions/interface.itr8RangeAsync.html https://mrft.github.io/itr8/functions/operators.skipWhile.html +https://mrft.github.io/itr8/functions/operators.average.html +https://mrft.github.io/itr8/functions/operators.distribute.html +https://mrft.github.io/itr8/functions/interface.itr8Interval.html +https://mrft.github.io/itr8/functions/operators.mostRecent.html +https://mrft.github.io/itr8/functions/operators.zip.html +https://mrft.github.io/itr8/functions/util.thenableFactory.html +https://mrft.github.io/itr8/functions/interface.itr8FromStringAsync.html +https://mrft.github.io/itr8/functions/peer.itr8FromObservable.html https://mrft.github.io/itr8/functions/operators.intersperse.html +https://mrft.github.io/itr8/functions/operators.some.html +https://mrft.github.io/itr8/functions/operators.groupPer.html https://mrft.github.io/itr8/functions/operators.repeatEach.html -https://mrft.github.io/itr8/functions/peer.itr8FromStream.html +https://mrft.github.io/itr8/functions/operators.split.html +https://mrft.github.io/itr8/functions/operators.runningAverage.html +https://mrft.github.io/itr8/functions/util.compose.html https://mrft.github.io/itr8/functions/interface.itr8FromIterable.html -https://mrft.github.io/itr8/functions/operators.stringToChar.html https://mrft.github.io/itr8/functions/interface.itr8Range.html -https://mrft.github.io/itr8/modules/interface.html +https://mrft.github.io/itr8/functions/util.pipe.html +https://mrft.github.io/itr8/functions/interface.forEach.html +https://mrft.github.io/itr8/functions/operators.runningReduce.html +https://mrft.github.io/itr8/functions/util.isPromise.html +https://mrft.github.io/itr8/functions/util.doAfterFactory.html +https://mrft.github.io/itr8/functions/operators.max.html +https://mrft.github.io/itr8/functions/operators.debounce.html +https://mrft.github.io/itr8/types/index.TTransIteratorSyncOrAsync.html +https://mrft.github.io/itr8/types/index.TPushable.html +https://mrft.github.io/itr8/types/index.TNextFnResult.html +https://mrft.github.io/itr8/types/index.TThenable.html +https://mrft.github.io/itr8/modules.html +https://mrft.github.io/itr8/variables/util.AsyncFunction.html https://mrft.github.io/itr8/modules/operators.html https://mrft.github.io/itr8/modules/peer.html +https://mrft.github.io/itr8/modules/interface.html https://mrft.github.io/itr8/modules/util.html https://mrft.github.io/itr8/modules/index.html -https://mrft.github.io/itr8/modules.html -https://mrft.github.io/itr8/index.html -https://mrft.github.io/itr8/variables/util.AsyncFunction.html -https://mrft.github.io/itr8/pages/CHANGELOG.html https://mrft.github.io/itr8/pages/ROADMAP.html -https://mrft.github.io/itr8/types/index.TThenable.html -https://mrft.github.io/itr8/types/index.TTransIteratorSyncOrAsync.html -https://mrft.github.io/itr8/types/index.TPushable.html -https://mrft.github.io/itr8/types/index.TNextFnResult.html +https://mrft.github.io/itr8/pages/CHANGELOG.html +https://mrft.github.io/itr8/index.html diff --git a/docs/types/index.TNextFnResult.html b/docs/types/index.TNextFnResult.html index b178595..76d2064 100644 --- a/docs/types/index.TNextFnResult.html +++ b/docs/types/index.TNextFnResult.html @@ -27,7 +27,7 @@

        TOut

      • TState

    +
  • Defined in types.ts:27
  • +
  • Defined in types.ts:4
  • +
  • Defined in types.ts:57
  • +
  • Defined in types.ts:20
  • +
  • Defined in util/index.ts:50