Socket
Socket
Sign inDemoInstall

@rimbu/stream

Package Overview
Dependencies
3
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.13.4 to 0.13.5

36

dist/main/custom/fast-iterator-custom.js

@@ -7,3 +7,2 @@ "use strict";

var common_1 = require("@rimbu/common");
var custom_1 = require("@rimbu/stream/custom");
exports.fixedDoneIteratorResult = Object.freeze({

@@ -44,6 +43,7 @@ done: true,

tslib_1.__extends(FlatMapIterator, _super);
function FlatMapIterator(source, flatMapFun) {
function FlatMapIterator(source, flatMapFun, streamSourceHelpers) {
var _this = _super.call(this) || this;
_this.source = source;
_this.flatMapFun = flatMapFun;
_this.streamSourceHelpers = streamSourceHelpers;
_this.state = (0, common_1.TraverseState)();

@@ -69,3 +69,4 @@ _this.done = false;

var nextSource = this.flatMapFun(nextIter, state.nextIndex(), state.halt);
this.currentIterator = (0, custom_1.fromStreamSource)(nextSource)[Symbol.iterator]();
this.currentIterator = this.streamSourceHelpers
.fromStreamSource(nextSource)[Symbol.iterator]();
}

@@ -79,6 +80,7 @@ return nextValue;

tslib_1.__extends(ConcatIterator, _super);
function ConcatIterator(source, otherSources) {
function ConcatIterator(source, otherSources, streamSourceHelpers) {
var _this = _super.call(this) || this;
_this.source = source;
_this.otherSources = otherSources;
_this.streamSourceHelpers = streamSourceHelpers;
_this.sourceIndex = 0;

@@ -92,2 +94,3 @@ _this.iterator = source[Symbol.iterator]();

var length = this.otherSources.length;
var streamSourceHelpers = this.streamSourceHelpers;
while (done === (value = this.iterator.fastNext(done))) {

@@ -97,3 +100,3 @@ if (this.sourceIndex >= length)

var nextSource = this.otherSources[this.sourceIndex++];
while ((0, custom_1.isEmptyStreamSourceInstance)(nextSource)) {
while (streamSourceHelpers.isEmptyStreamSourceInstance(nextSource)) {
if (this.sourceIndex >= length)

@@ -103,3 +106,4 @@ return (0, common_1.OptLazy)(otherwise);

}
this.iterator = (0, custom_1.fromStreamSource)(nextSource)[Symbol.iterator]();
this.iterator = streamSourceHelpers
.fromStreamSource(nextSource)[Symbol.iterator]();
}

@@ -610,7 +614,7 @@ return value;

tslib_1.__extends(MapApplyIterator, _super);
function MapApplyIterator(source, f, args) {
function MapApplyIterator(source, f, args, streamSourceHelpers) {
var _this = _super.call(this) || this;
_this.f = f;
_this.args = args;
_this.iter = (0, custom_1.fromStreamSource)(source)[Symbol.iterator]();
_this.iter = streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
return _this;

@@ -631,3 +635,3 @@ }

tslib_1.__extends(FilterApplyIterator, _super);
function FilterApplyIterator(source, pred, args, invert) {
function FilterApplyIterator(source, pred, args, invert, streamSourceHelpers) {
var _this = _super.call(this) || this;

@@ -637,3 +641,3 @@ _this.pred = pred;

_this.invert = invert;
_this.iter = (0, custom_1.fromStreamSource)(source)[Symbol.iterator]();
_this.iter = streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
return _this;

@@ -766,7 +770,9 @@ }

tslib_1.__extends(ZipWithIterator, _super);
function ZipWithIterator(iterables, zipFun) {
function ZipWithIterator(iterables, zipFun, streamSourceHelpers) {
var _this = _super.call(this) || this;
_this.iterables = iterables;
_this.zipFun = zipFun;
_this.sources = iterables.map(function (source) { return (0, custom_1.fromStreamSource)(source)[Symbol.iterator](); });
_this.sources = iterables.map(function (source) {
return streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
});
return _this;

@@ -792,3 +798,3 @@ }

tslib_1.__extends(ZipAllWithItererator, _super);
function ZipAllWithItererator(fillValue, iters, zipFun) {
function ZipAllWithItererator(fillValue, iters, zipFun, streamSourceHelpers) {
var _this = _super.call(this) || this;

@@ -799,3 +805,5 @@ _this.fillValue = fillValue;

_this.allDone = false;
_this.sources = iters.map(function (o) { return (0, custom_1.fromStreamSource)(o)[Symbol.iterator](); });
_this.sources = iters.map(function (o) {
return streamSourceHelpers.fromStreamSource(o)[Symbol.iterator]();
});
return _this;

@@ -802,0 +810,0 @@ }

import { __awaiter } from "tslib";
import { Token } from '@rimbu/base';
import { AsyncOptLazy, CollectFun, TraverseState, } from '@rimbu/common';
import { closeIters, fromAsyncStreamSource, isEmptyAsyncStreamSourceInstance, } from '@rimbu/stream/async-custom';
import { closeIters, } from '@rimbu/stream/async-custom';
export const fixedDoneAsyncIteratorResult = Object.freeze(Promise.resolve(Object.freeze({

@@ -46,3 +46,3 @@ done: true,

export class FromResourceIterator extends AsyncFastIteratorBase {
constructor(open, createSource, close) {
constructor(open, createSource, close, asyncStreamSourceHelpers) {
super();

@@ -52,2 +52,3 @@ this.open = open;

this.close = close;
this.asyncStreamSourceHelpers = asyncStreamSourceHelpers;
this.return = () => __awaiter(this, void 0, void 0, function* () {

@@ -66,3 +67,4 @@ var _a, _b;

const source = yield this.createSource(resource);
this.iterator = fromAsyncStreamSource(source)[Symbol.asyncIterator]();
this.iterator = this.asyncStreamSourceHelpers
.fromAsyncStreamSource(source)[Symbol.asyncIterator]();
}

@@ -102,7 +104,9 @@ return this.iterator.fastNext(() => __awaiter(this, void 0, void 0, function* () {

export class AsyncZipWithIterator extends AsyncFastIteratorBase {
constructor(iterables, zipFun) {
constructor(iterables, zipFun, asyncStreamSourceHelpers) {
super();
this.iterables = iterables;
this.zipFun = zipFun;
this.sources = iterables.map((source) => fromAsyncStreamSource(source)[Symbol.asyncIterator]());
this.asyncStreamSourceHelpers = asyncStreamSourceHelpers;
this.sources = iterables.map((source) => this.asyncStreamSourceHelpers
.fromAsyncStreamSource(source)[Symbol.asyncIterator]());
this.sourcesToClose = new Set(this.sources);

@@ -128,3 +132,3 @@ this.return = () => closeIters(...this.sourcesToClose);

export class AsyncZipAllWithItererator extends AsyncFastIteratorBase {
constructor(fillValue, iters, zipFun) {
constructor(fillValue, iters, zipFun, asyncStreamSourceHelpers) {
super();

@@ -134,3 +138,5 @@ this.fillValue = fillValue;

this.zipFun = zipFun;
this.sources = iters.map((o) => fromAsyncStreamSource(o)[Symbol.asyncIterator]());
this.asyncStreamSourceHelpers = asyncStreamSourceHelpers;
this.sources = iters.map((o) => this.asyncStreamSourceHelpers
.fromAsyncStreamSource(o)[Symbol.asyncIterator]());
this.sourcesToClose = new Set(this.sources);

@@ -207,5 +213,6 @@ this.return = () => closeIters(...this.sourcesToClose);

export class FromPromise extends AsyncFastIteratorBase {
constructor(promise, close) {
constructor(promise, asyncStreamSourceHelpers, close) {
super();
this.promise = promise;
this.asyncStreamSourceHelpers = asyncStreamSourceHelpers;
this.return = () => __awaiter(this, void 0, void 0, function* () {

@@ -223,3 +230,4 @@ var _a, _b;

const source = yield this.promise();
this.iterator = fromAsyncStreamSource(source)[Symbol.asyncIterator]();
this.iterator = this.asyncStreamSourceHelpers
.fromAsyncStreamSource(source)[Symbol.asyncIterator]();
}

@@ -373,6 +381,7 @@ return this.iterator.fastNext(otherwise);

export class AsyncFlatMapIterator extends AsyncFastIteratorBase {
constructor(source, flatMapFun) {
constructor(source, flatMapFun, asyncStreamSourceHelpers) {
super();
this.source = source;
this.flatMapFun = flatMapFun;
this.asyncStreamSourceHelpers = asyncStreamSourceHelpers;
this.state = TraverseState();

@@ -392,2 +401,3 @@ this.done = false;

let nextValue;
const { asyncStreamSourceHelpers } = this;
while (null === this.currentIterator ||

@@ -401,3 +411,4 @@ done === (nextValue = yield this.currentIterator.fastNext(done))) {

const nextSource = this.flatMapFun(nextIter, state.nextIndex(), state.halt);
const currentIterator = fromAsyncStreamSource(nextSource)[Symbol.asyncIterator]();
const currentIterator = asyncStreamSourceHelpers
.fromAsyncStreamSource(nextSource)[Symbol.asyncIterator]();
this.currentIterator = currentIterator;

@@ -410,6 +421,7 @@ }

export class AsyncConcatIterator extends AsyncFastIteratorBase {
constructor(source, otherSources) {
constructor(source, otherSources, asyncStreamSourceHelpers) {
super();
this.source = source;
this.otherSources = otherSources;
this.asyncStreamSourceHelpers = asyncStreamSourceHelpers;
this.sourceIndex = 0;

@@ -424,2 +436,3 @@ this.iterator = source[Symbol.asyncIterator]();

const length = this.otherSources.length;
const { asyncStreamSourceHelpers } = this;
while (done === (value = yield this.iterator.fastNext(done))) {

@@ -430,3 +443,3 @@ if (this.sourceIndex >= length) {

let nextSource = this.otherSources[this.sourceIndex++];
while (isEmptyAsyncStreamSourceInstance(nextSource)) {
while (asyncStreamSourceHelpers.isEmptyAsyncStreamSourceInstance(nextSource)) {
if (this.sourceIndex >= length) {

@@ -437,3 +450,4 @@ return AsyncOptLazy.toMaybePromise(otherwise);

}
this.iterator = fromAsyncStreamSource(nextSource)[Symbol.asyncIterator]();
this.iterator = asyncStreamSourceHelpers
.fromAsyncStreamSource(nextSource)[Symbol.asyncIterator]();
}

@@ -440,0 +454,0 @@ return value;

var _a;
import { __awaiter } from "tslib";
import { RimbuError } from '@rimbu/base';
import { AsyncOptLazy, AsyncReducer, Comp, Eq, TraverseState, } from '@rimbu/common';
import { RimbuError } from '@rimbu/base';
import { closeIters, emptyAsyncFastIterator, FromAsyncIterator, FromIterator, FromPromise, isAsyncFastIterator, FromResourceIterator, AsyncUnfoldIterator, AsyncZipWithIterator, AsyncZipAllWithItererator, AsyncAppendIterator, AsyncCollectIterator, AsyncConcatIterator, AsyncDropIterator, AsyncSplitWhereIterator, AsyncDistinctPreviousIterator, AsyncDropWhileIterator, AsyncFilterIterator, AsyncFilterPureIterator, AsyncFlatMapIterator, AsyncFoldIterator, AsyncIndexedIterator, AsyncIndicesOfIterator, AsyncIndicesWhereIterator, AsyncIntersperseIterator, AsyncMapIterator, AsyncMapPureIterator, AsyncOfIterator, AsyncPrependIterator, AsyncReduceAllIterator, AsyncReduceIterator, AsyncRepeatIterator, AsyncSplitOnIterator, AsyncTakeIterator, AsyncTakeWhileIterator, AsyncWindowIterator, AsyncLiveIterator, } from '@rimbu/stream/async-custom';
import { Stream } from '@rimbu/stream';
import { AsyncAppendIterator, AsyncCollectIterator, AsyncConcatIterator, AsyncDistinctPreviousIterator, AsyncDropIterator, AsyncDropWhileIterator, AsyncFilterIterator, AsyncFilterPureIterator, AsyncFlatMapIterator, AsyncFoldIterator, AsyncIndexedIterator, AsyncIndicesOfIterator, AsyncIndicesWhereIterator, AsyncIntersperseIterator, AsyncLiveIterator, AsyncMapIterator, AsyncMapPureIterator, AsyncOfIterator, AsyncPrependIterator, AsyncReduceAllIterator, AsyncReduceIterator, AsyncRepeatIterator, AsyncSplitOnIterator, AsyncSplitWhereIterator, AsyncTakeIterator, AsyncTakeWhileIterator, AsyncUnfoldIterator, AsyncWindowIterator, AsyncZipAllWithItererator, AsyncZipWithIterator, FromAsyncIterator, FromIterator, FromPromise, FromResourceIterator, closeIters, emptyAsyncFastIterator, isAsyncFastIterator, } from '@rimbu/stream/async-custom';
import { isEmptyStreamSourceInstance } from '@rimbu/stream/custom';

@@ -793,3 +793,3 @@ export class AsyncStreamBase {

[Symbol.asyncIterator]() {
return new AsyncFlatMapIterator(this.source, this.flatmapFun);
return new AsyncFlatMapIterator(this.source, this.flatmapFun, asyncStreamSourceHelpers);
}

@@ -804,3 +804,3 @@ }

[Symbol.asyncIterator]() {
return new AsyncConcatIterator(this.source, this.others);
return new AsyncConcatIterator(this.source, this.others, asyncStreamSourceHelpers);
}

@@ -1251,3 +1251,3 @@ }

[Symbol.asyncIterator]() {
return new FromResourceIterator(this.open, this.createSource, this.close);
return new FromResourceIterator(this.open, this.createSource, this.close, asyncStreamSourceHelpers);
}

@@ -1262,3 +1262,3 @@ }

if (source instanceof Function) {
return new FromPromise(source, close);
return new FromPromise(source, asyncStreamSourceHelpers, close);
}

@@ -1306,2 +1306,6 @@ if (isEmptyAsyncStreamSourceInstance(source)) {

};
const asyncStreamSourceHelpers = {
fromAsyncStreamSource,
isEmptyAsyncStreamSourceInstance,
};
export const AsyncStreamConstructorsImpl = Object.freeze({

@@ -1365,3 +1369,3 @@ of(...values) {

}
return new AsyncFromStream(() => new AsyncZipWithIterator(sources, zipFun));
return new AsyncFromStream(() => new AsyncZipWithIterator(sources, zipFun, asyncStreamSourceHelpers));
};

@@ -1377,3 +1381,3 @@ },

}
return new AsyncFromStream(() => new AsyncZipAllWithItererator(fillValue, sources, zipFun));
return new AsyncFromStream(() => new AsyncZipAllWithItererator(fillValue, sources, zipFun, asyncStreamSourceHelpers));
};

@@ -1380,0 +1384,0 @@ },

import { Token } from '@rimbu/base';
import { CollectFun, OptLazy, TraverseState } from '@rimbu/common';
import { fromStreamSource, isEmptyStreamSourceInstance, } from '@rimbu/stream/custom';
export const fixedDoneIteratorResult = Object.freeze({

@@ -33,6 +32,7 @@ done: true,

export class FlatMapIterator extends FastIteratorBase {
constructor(source, flatMapFun) {
constructor(source, flatMapFun, streamSourceHelpers) {
super();
this.source = source;
this.flatMapFun = flatMapFun;
this.streamSourceHelpers = streamSourceHelpers;
this.state = TraverseState();

@@ -57,3 +57,4 @@ this.done = false;

const nextSource = this.flatMapFun(nextIter, state.nextIndex(), state.halt);
this.currentIterator = fromStreamSource(nextSource)[Symbol.iterator]();
this.currentIterator = this.streamSourceHelpers
.fromStreamSource(nextSource)[Symbol.iterator]();
}

@@ -64,6 +65,7 @@ return nextValue;

export class ConcatIterator extends FastIteratorBase {
constructor(source, otherSources) {
constructor(source, otherSources, streamSourceHelpers) {
super();
this.source = source;
this.otherSources = otherSources;
this.streamSourceHelpers = streamSourceHelpers;
this.sourceIndex = 0;

@@ -76,2 +78,3 @@ this.iterator = source[Symbol.iterator]();

const length = this.otherSources.length;
const { streamSourceHelpers } = this;
while (done === (value = this.iterator.fastNext(done))) {

@@ -81,3 +84,3 @@ if (this.sourceIndex >= length)

let nextSource = this.otherSources[this.sourceIndex++];
while (isEmptyStreamSourceInstance(nextSource)) {
while (streamSourceHelpers.isEmptyStreamSourceInstance(nextSource)) {
if (this.sourceIndex >= length)

@@ -87,3 +90,4 @@ return OptLazy(otherwise);

}
this.iterator = fromStreamSource(nextSource)[Symbol.iterator]();
this.iterator = streamSourceHelpers
.fromStreamSource(nextSource)[Symbol.iterator]();
}

@@ -517,7 +521,7 @@ return value;

export class MapApplyIterator extends FastIteratorBase {
constructor(source, f, args) {
constructor(source, f, args, streamSourceHelpers) {
super();
this.f = f;
this.args = args;
this.iter = fromStreamSource(source)[Symbol.iterator]();
this.iter = streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
}

@@ -534,3 +538,3 @@ fastNext(otherwise) {

export class FilterApplyIterator extends FastIteratorBase {
constructor(source, pred, args, invert) {
constructor(source, pred, args, invert, streamSourceHelpers) {
super();

@@ -540,3 +544,3 @@ this.pred = pred;

this.invert = invert;
this.iter = fromStreamSource(source)[Symbol.iterator]();
this.iter = streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
}

@@ -641,7 +645,7 @@ fastNext(otherwise) {

export class ZipWithIterator extends FastIteratorBase {
constructor(iterables, zipFun) {
constructor(iterables, zipFun, streamSourceHelpers) {
super();
this.iterables = iterables;
this.zipFun = zipFun;
this.sources = iterables.map((source) => fromStreamSource(source)[Symbol.iterator]());
this.sources = iterables.map((source) => streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]());
}

@@ -663,3 +667,3 @@ fastNext(otherwise) {

export class ZipAllWithItererator extends FastIteratorBase {
constructor(fillValue, iters, zipFun) {
constructor(fillValue, iters, zipFun, streamSourceHelpers) {
super();

@@ -670,3 +674,3 @@ this.fillValue = fillValue;

this.allDone = false;
this.sources = iters.map((o) => fromStreamSource(o)[Symbol.iterator]());
this.sources = iters.map((o) => streamSourceHelpers.fromStreamSource(o)[Symbol.iterator]());
}

@@ -673,0 +677,0 @@ fastNext(otherwise) {

var _a;
import { RimbuError } from '@rimbu/base';
import { Comp, Eq, ErrBase, IndexRange, OptLazy, Range, Reducer, TraverseState, } from '@rimbu/common';
import { isFastIterator, emptyFastIterator, FlatMapIterator, ConcatIterator, FilterIterator, FilterPureIterator, IndicesWhereIterator, IndicesOfIterator, TakeWhileIterator, DropWhileIterator, TakeIterator, DropIterator, IntersperseIterator, SplitWhereIterator, SplitOnIterator, ReduceIterator, ReduceAllIterator, RepeatIterator, CollectIterator, ArrayIterator, ArrayReverseIterator, AlwaysIterator, MapApplyIterator, FilterApplyIterator, RangeDownIterator, RangeUpIterator, RandomIntIterator, RandomIterator, UnfoldIterator, ZipAllWithItererator, ZipWithIterator, AppendIterator, IndexedIterator, MapIterator, MapPureIterator, PrependIterator, DistinctPreviousIterator, WindowIterator, } from '@rimbu/stream/custom';
import { RimbuError } from '@rimbu/base';
import { AlwaysIterator, AppendIterator, ArrayIterator, ArrayReverseIterator, CollectIterator, ConcatIterator, DistinctPreviousIterator, DropIterator, DropWhileIterator, FilterApplyIterator, FilterIterator, FilterPureIterator, FlatMapIterator, IndexedIterator, IndicesOfIterator, IndicesWhereIterator, IntersperseIterator, MapApplyIterator, MapIterator, MapPureIterator, PrependIterator, RandomIntIterator, RandomIterator, RangeDownIterator, RangeUpIterator, ReduceAllIterator, ReduceIterator, RepeatIterator, SplitOnIterator, SplitWhereIterator, TakeIterator, TakeWhileIterator, UnfoldIterator, WindowIterator, ZipAllWithItererator, ZipWithIterator, emptyFastIterator, isFastIterator, } from '@rimbu/stream/custom';
function* yieldObjKeys(obj) {

@@ -589,3 +589,3 @@ for (const key in obj) {

[Symbol.iterator]() {
return new FlatMapIterator(this.source, this.flatmapFun);
return new FlatMapIterator(this.source, this.flatmapFun, streamSourceHelpers);
}

@@ -600,3 +600,3 @@ }

[Symbol.iterator]() {
return new ConcatIterator(this.source, this.otherSources);
return new ConcatIterator(this.source, this.otherSources, streamSourceHelpers);
}

@@ -1280,3 +1280,3 @@ forEach(f, state = TraverseState()) {

[Symbol.iterator]() {
return new MapApplyIterator(this.source, this.f, this.args);
return new MapApplyIterator(this.source, this.f, this.args, streamSourceHelpers);
}

@@ -1293,3 +1293,3 @@ }

[Symbol.iterator]() {
return new FilterApplyIterator(this.source, this.pred, this.args, this.invert);
return new FilterApplyIterator(this.source, this.pred, this.args, this.invert, streamSourceHelpers);
}

@@ -1373,2 +1373,6 @@ }

}
const streamSourceHelpers = {
fromStreamSource,
isEmptyStreamSourceInstance,
};
export const StreamConstructorsImpl = Object.freeze({

@@ -1487,3 +1491,3 @@ empty() {

}
return new FromStream(() => new ZipWithIterator(sources, zipFun));
return new FromStream(() => new ZipWithIterator(sources, zipFun, streamSourceHelpers));
};

@@ -1499,3 +1503,3 @@ },

}
return new FromStream(() => new ZipAllWithItererator(fillValue, sources, zipFun));
return new FromStream(() => new ZipAllWithItererator(fillValue, sources, zipFun, streamSourceHelpers));
};

@@ -1502,0 +1506,0 @@ },

import { Token } from '@rimbu/base';
import { ArrayNonEmpty, AsyncCollectFun, AsyncOptLazy, AsyncReducer, Eq, MaybePromise, TraverseState } from '@rimbu/common';
import type { AsyncFastIterator, AsyncStream, AsyncStreamSource } from '@rimbu/stream/async';
import { type AsyncStreamSourceHelpers } from '@rimbu/stream/async-custom';
export declare const fixedDoneAsyncIteratorResult: Readonly<Promise<IteratorResult<any, any>>>;

@@ -22,3 +23,4 @@ export declare function isAsyncFastIterator<T>(iterator: AsyncIterator<T>): iterator is AsyncFastIterator<T>;

readonly close: (resource: R) => MaybePromise<void>;
constructor(open: () => MaybePromise<R>, createSource: (resource: R) => MaybePromise<AsyncStreamSource<T>>, close: (resource: R) => MaybePromise<void>);
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers;
constructor(open: () => MaybePromise<R>, createSource: (resource: R) => MaybePromise<AsyncStreamSource<T>>, close: (resource: R) => MaybePromise<void>, asyncStreamSourceHelpers: AsyncStreamSourceHelpers);
resource?: R;

@@ -40,5 +42,6 @@ iterator?: AsyncFastIterator<T>;

readonly zipFun: (...values: I) => MaybePromise<R>;
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers;
constructor(iterables: {
[K in keyof I]: AsyncStreamSource<I[K]>;
}, zipFun: (...values: I) => MaybePromise<R>);
}, zipFun: (...values: I) => MaybePromise<R>, asyncStreamSourceHelpers: AsyncStreamSourceHelpers);
readonly sources: AsyncFastIterator<any>[];

@@ -56,2 +59,3 @@ readonly sourcesToClose: Set<AsyncFastIterator<any>>;

}) => MaybePromise<R>;
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers;
constructor(fillValue: AsyncOptLazy<F>, iters: {

@@ -61,3 +65,3 @@ [K in keyof I]: AsyncStreamSource<I[K]>;

[K in keyof I]: I[K] | F;
}) => MaybePromise<R>);
}) => MaybePromise<R>, asyncStreamSourceHelpers: AsyncStreamSourceHelpers);
readonly sources: AsyncFastIterator<any>[];

@@ -82,3 +86,4 @@ readonly sourcesToClose: Set<AsyncFastIterator<any>>;

readonly promise: () => Promise<AsyncStreamSource<T>>;
constructor(promise: () => Promise<AsyncStreamSource<T>>, close?: () => MaybePromise<void>);
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers;
constructor(promise: () => Promise<AsyncStreamSource<T>>, asyncStreamSourceHelpers: AsyncStreamSourceHelpers, close?: () => MaybePromise<void>);
iterator: AsyncFastIterator<T> | undefined;

@@ -139,4 +144,5 @@ fastNext<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;

readonly flatMapFun: (value: T, index: number, halt: () => void) => AsyncStreamSource<T2>;
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers;
iterator: AsyncFastIterator<T>;
constructor(source: AsyncStream<T>, flatMapFun: (value: T, index: number, halt: () => void) => AsyncStreamSource<T2>);
constructor(source: AsyncStream<T>, flatMapFun: (value: T, index: number, halt: () => void) => AsyncStreamSource<T2>, asyncStreamSourceHelpers: AsyncStreamSourceHelpers);
readonly state: TraverseState;

@@ -150,4 +156,5 @@ done: boolean;

readonly otherSources: AsyncStreamSource<T>[];
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers;
iterator: AsyncFastIterator<T>;
constructor(source: AsyncStream<T>, otherSources: AsyncStreamSource<T>[]);
constructor(source: AsyncStream<T>, otherSources: AsyncStreamSource<T>[], asyncStreamSourceHelpers: AsyncStreamSourceHelpers);
sourceIndex: number;

@@ -154,0 +161,0 @@ fastNext<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;

@@ -112,2 +112,11 @@ import { ArrayNonEmpty, AsyncCollectFun, AsyncOptLazy, AsyncReducer, Eq, MaybePromise, ToJSON, TraverseState } from '@rimbu/common';

};
declare const asyncStreamSourceHelpers: {
fromAsyncStreamSource: {
<T>(source: AsyncStreamSource.NonEmpty<T>): AsyncStream.NonEmpty<T>;
<T_1>(source: AsyncStreamSource<T_1>): AsyncStream<T_1>;
};
isEmptyAsyncStreamSourceInstance: typeof isEmptyAsyncStreamSourceInstance;
};
export type AsyncStreamSourceHelpers = typeof asyncStreamSourceHelpers;
export declare const AsyncStreamConstructorsImpl: AsyncStreamConstructors;
export {};
import { Token } from '@rimbu/base';
import { CollectFun, Eq, OptLazy, Reducer, TraverseState } from '@rimbu/common';
import type { FastIterator, Stream, StreamSource } from '@rimbu/stream';
import type { StreamSourceHelpers } from '@rimbu/stream/custom';
export declare const fixedDoneIteratorResult: IteratorResult<any>;

@@ -18,4 +19,5 @@ export declare const emptyFastIterator: FastIterator<any>;

readonly flatMapFun: (value: T, index: number, halt: () => void) => StreamSource<T2>;
readonly streamSourceHelpers: StreamSourceHelpers;
iterator: FastIterator<T>;
constructor(source: Stream<T>, flatMapFun: (value: T, index: number, halt: () => void) => StreamSource<T2>);
constructor(source: Stream<T>, flatMapFun: (value: T, index: number, halt: () => void) => StreamSource<T2>, streamSourceHelpers: StreamSourceHelpers);
readonly state: TraverseState;

@@ -29,4 +31,5 @@ done: boolean;

readonly otherSources: StreamSource<T>[];
readonly streamSourceHelpers: StreamSourceHelpers;
iterator: FastIterator<T>;
constructor(source: Stream<T>, otherSources: StreamSource<T>[]);
constructor(source: Stream<T>, otherSources: StreamSource<T>[], streamSourceHelpers: StreamSourceHelpers);
sourceIndex: number;

@@ -179,3 +182,3 @@ fastNext<O>(otherwise?: OptLazy<O>): T | O;

readonly args: A;
constructor(source: StreamSource<T>, f: (...args: [...T, ...A]) => R, args: A);
constructor(source: StreamSource<T>, f: (...args: [...T, ...A]) => R, args: A, streamSourceHelpers: StreamSourceHelpers);
iter: FastIterator<T>;

@@ -188,3 +191,3 @@ fastNext<O>(otherwise?: OptLazy<O>): R | O;

readonly invert: boolean;
constructor(source: StreamSource<T>, pred: (...args: [...T, ...A]) => boolean, args: A, invert: boolean);
constructor(source: StreamSource<T>, pred: (...args: [...T, ...A]) => boolean, args: A, invert: boolean, streamSourceHelpers: StreamSourceHelpers);
iter: FastIterator<T>;

@@ -233,3 +236,3 @@ fastNext<O>(otherwise?: OptLazy<O>): T | O;

[K in keyof I]: StreamSource<I[K]>;
}, zipFun: (...values: I) => R);
}, zipFun: (...values: I) => R, streamSourceHelpers: StreamSourceHelpers);
readonly sources: FastIterator<any>[];

@@ -250,3 +253,3 @@ fastNext<O>(otherwise?: OptLazy<O>): R | O;

[K in keyof I]: I[K] | F;
}) => R);
}) => R, streamSourceHelpers: StreamSourceHelpers);
readonly sources: FastIterator<any>[];

@@ -253,0 +256,0 @@ allDone: boolean;

@@ -175,2 +175,11 @@ import { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common';

export declare function isEmptyStreamSourceInstance(source: StreamSource<unknown>): boolean;
declare const streamSourceHelpers: {
fromStreamSource: {
<T>(source: StreamSource.NonEmpty<T>): Stream.NonEmpty<T>;
<T_1>(source: StreamSource<T_1>): Stream<T_1>;
};
isEmptyStreamSourceInstance: typeof isEmptyStreamSourceInstance;
};
export type StreamSourceHelpers = typeof streamSourceHelpers;
export declare const StreamConstructorsImpl: StreamConstructors;
export {};
{
"name": "@rimbu/stream",
"version": "0.13.4",
"version": "0.13.5",
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript",

@@ -114,3 +114,3 @@ "keywords": [

},
"gitHead": "8f83f7bc9812a739279a64e2e52d83f631dfb4f6"
"gitHead": "8e4ec725c03e43d64d0e3f36c380a295816d66e5"
}

@@ -13,7 +13,2 @@ import { Token } from '@rimbu/base';

import {
closeIters,
fromAsyncStreamSource,
isEmptyAsyncStreamSourceInstance,
} from '@rimbu/stream/async-custom';
import type {

@@ -24,2 +19,6 @@ AsyncFastIterator,

} from '@rimbu/stream/async';
import {
closeIters,
type AsyncStreamSourceHelpers,
} from '@rimbu/stream/async-custom';

@@ -83,3 +82,4 @@ export const fixedDoneAsyncIteratorResult = Object.freeze(

readonly createSource: (resource: R) => MaybePromise<AsyncStreamSource<T>>,
readonly close: (resource: R) => MaybePromise<void>
readonly close: (resource: R) => MaybePromise<void>,
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers
) {

@@ -102,3 +102,5 @@ super();

const source = await this.createSource(resource);
this.iterator = fromAsyncStreamSource(source)[Symbol.asyncIterator]();
this.iterator = this.asyncStreamSourceHelpers
.fromAsyncStreamSource(source)
[Symbol.asyncIterator]();
}

@@ -155,3 +157,4 @@

readonly iterables: { [K in keyof I]: AsyncStreamSource<I[K]> },
readonly zipFun: (...values: I) => MaybePromise<R>
readonly zipFun: (...values: I) => MaybePromise<R>,
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers
) {

@@ -162,3 +165,5 @@ super();

(source): AsyncFastIterator<any> =>
fromAsyncStreamSource(source)[Symbol.asyncIterator]()
this.asyncStreamSourceHelpers
.fromAsyncStreamSource(source)
[Symbol.asyncIterator]()
);

@@ -207,3 +212,4 @@

...values: { [K in keyof I]: I[K] | F }
) => MaybePromise<R>
) => MaybePromise<R>,
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers
) {

@@ -214,3 +220,5 @@ super();

(o): AsyncFastIterator<any> =>
fromAsyncStreamSource(o)[Symbol.asyncIterator]()
this.asyncStreamSourceHelpers
.fromAsyncStreamSource(o)
[Symbol.asyncIterator]()
);

@@ -313,2 +321,3 @@

readonly promise: () => Promise<AsyncStreamSource<T>>,
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers,
close?: () => MaybePromise<void>

@@ -328,5 +337,5 @@ ) {

const source = await this.promise();
this.iterator = fromAsyncStreamSource(source)[
Symbol.asyncIterator
]() as any;
this.iterator = this.asyncStreamSourceHelpers
.fromAsyncStreamSource(source)
[Symbol.asyncIterator]() as any;
}

@@ -526,3 +535,4 @@

halt: () => void
) => AsyncStreamSource<T2>
) => AsyncStreamSource<T2>,
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers
) {

@@ -551,2 +561,4 @@ super();

const { asyncStreamSourceHelpers } = this;
while (

@@ -569,4 +581,5 @@ null === this.currentIterator ||

const currentIterator =
fromAsyncStreamSource(nextSource)[Symbol.asyncIterator]();
const currentIterator = asyncStreamSourceHelpers
.fromAsyncStreamSource(nextSource)
[Symbol.asyncIterator]();

@@ -585,3 +598,4 @@ this.currentIterator = currentIterator;

readonly source: AsyncStream<T>,
readonly otherSources: AsyncStreamSource<T>[]
readonly otherSources: AsyncStreamSource<T>[],
readonly asyncStreamSourceHelpers: AsyncStreamSourceHelpers
) {

@@ -600,2 +614,3 @@ super();

const length = this.otherSources.length;
const { asyncStreamSourceHelpers } = this;

@@ -610,3 +625,5 @@ while (done === (value = await this.iterator.fastNext(done))) {

while (isEmptyAsyncStreamSourceInstance(nextSource)) {
while (
asyncStreamSourceHelpers.isEmptyAsyncStreamSourceInstance(nextSource)
) {
if (this.sourceIndex >= length) {

@@ -618,3 +635,5 @@ return AsyncOptLazy.toMaybePromise(otherwise!);

this.iterator = fromAsyncStreamSource(nextSource)[Symbol.asyncIterator]();
this.iterator = asyncStreamSourceHelpers
.fromAsyncStreamSource(nextSource)
[Symbol.asyncIterator]();
}

@@ -621,0 +640,0 @@

@@ -0,1 +1,2 @@

import { RimbuError, Token } from '@rimbu/base';
import {

@@ -12,4 +13,5 @@ ArrayNonEmpty,

} from '@rimbu/common';
import { RimbuError, Token } from '@rimbu/base';
import type { StreamSource } from '@rimbu/stream';
import { Stream } from '@rimbu/stream';
import type {

@@ -22,18 +24,7 @@ AsyncFastIterator,

import {
closeIters,
emptyAsyncFastIterator,
FromAsyncIterator,
FromIterator,
FromPromise,
isAsyncFastIterator,
FromResourceIterator,
AsyncUnfoldIterator,
AsyncZipWithIterator,
AsyncZipAllWithItererator,
AsyncAppendIterator,
AsyncCollectIterator,
AsyncConcatIterator,
AsyncDistinctPreviousIterator,
AsyncDropIterator,
AsyncSplitWhereIterator,
AsyncDistinctPreviousIterator,
AsyncDropWhileIterator,

@@ -48,2 +39,3 @@ AsyncFilterIterator,

AsyncIntersperseIterator,
AsyncLiveIterator,
AsyncMapIterator,

@@ -57,10 +49,18 @@ AsyncMapPureIterator,

AsyncSplitOnIterator,
AsyncSplitWhereIterator,
AsyncStreamConstructors,
AsyncTakeIterator,
AsyncTakeWhileIterator,
AsyncUnfoldIterator,
AsyncWindowIterator,
AsyncLiveIterator,
AsyncZipAllWithItererator,
AsyncZipWithIterator,
FromAsyncIterator,
FromIterator,
FromPromise,
FromResourceIterator,
closeIters,
emptyAsyncFastIterator,
isAsyncFastIterator,
} from '@rimbu/stream/async-custom';
import { Stream } from '@rimbu/stream';
import type { StreamSource } from '@rimbu/stream';
import { isEmptyStreamSourceInstance } from '@rimbu/stream/custom';

@@ -1054,3 +1054,7 @@

[Symbol.asyncIterator](): AsyncFastIterator<T2> {
return new AsyncFlatMapIterator<T, T2>(this.source, this.flatmapFun);
return new AsyncFlatMapIterator<T, T2>(
this.source,
this.flatmapFun,
asyncStreamSourceHelpers
);
}

@@ -1068,3 +1072,7 @@ }

[Symbol.asyncIterator](): AsyncFastIterator<T> {
return new AsyncConcatIterator(this.source, this.others);
return new AsyncConcatIterator(
this.source,
this.others,
asyncStreamSourceHelpers
);
}

@@ -1629,3 +1637,8 @@ }

[Symbol.asyncIterator](): AsyncFastIterator<T> {
return new FromResourceIterator(this.open, this.createSource, this.close);
return new FromResourceIterator(
this.open,
this.createSource,
this.close,
asyncStreamSourceHelpers
);
}

@@ -1652,3 +1665,3 @@ }

if (source instanceof Function) {
return new FromPromise(source as any, close);
return new FromPromise(source as any, asyncStreamSourceHelpers, close);
}

@@ -1712,2 +1725,9 @@

const asyncStreamSourceHelpers = {
fromAsyncStreamSource,
isEmptyAsyncStreamSourceInstance,
};
export type AsyncStreamSourceHelpers = typeof asyncStreamSourceHelpers;
export const AsyncStreamConstructorsImpl: AsyncStreamConstructors =

@@ -1789,3 +1809,4 @@ Object.freeze<AsyncStreamConstructors>({

return new AsyncFromStream(
() => new AsyncZipWithIterator(sources, zipFun)
() =>
new AsyncZipWithIterator(sources, zipFun, asyncStreamSourceHelpers)
);

@@ -1805,3 +1826,8 @@ };

(): AsyncFastIterator<any> =>
new AsyncZipAllWithItererator(fillValue, sources, zipFun)
new AsyncZipAllWithItererator(
fillValue,
sources,
zipFun,
asyncStreamSourceHelpers
)
);

@@ -1808,0 +1834,0 @@ };

import { Token } from '@rimbu/base';
import { CollectFun, Eq, OptLazy, Reducer, TraverseState } from '@rimbu/common';
import {
fromStreamSource,
isEmptyStreamSourceInstance,
} from '@rimbu/stream/custom';
import type { FastIterator, Stream, StreamSource } from '@rimbu/stream';
import type { StreamSourceHelpers } from '@rimbu/stream/custom';

@@ -53,3 +50,4 @@ export const fixedDoneIteratorResult: IteratorResult<any> = Object.freeze({

halt: () => void
) => StreamSource<T2>
) => StreamSource<T2>,
readonly streamSourceHelpers: StreamSourceHelpers
) {

@@ -91,3 +89,5 @@ super();

this.currentIterator = fromStreamSource(nextSource)[Symbol.iterator]();
this.currentIterator = this.streamSourceHelpers
.fromStreamSource(nextSource)
[Symbol.iterator]();
}

@@ -104,3 +104,4 @@

readonly source: Stream<T>,
readonly otherSources: StreamSource<T>[]
readonly otherSources: StreamSource<T>[],
readonly streamSourceHelpers: StreamSourceHelpers
) {

@@ -118,2 +119,3 @@ super();

const length = this.otherSources.length;
const { streamSourceHelpers } = this;

@@ -125,3 +127,3 @@ while (done === (value = this.iterator.fastNext(done))) {

while (isEmptyStreamSourceInstance(nextSource)) {
while (streamSourceHelpers.isEmptyStreamSourceInstance(nextSource)) {
if (this.sourceIndex >= length) return OptLazy(otherwise) as O;

@@ -131,3 +133,5 @@ nextSource = this.otherSources[this.sourceIndex++];

this.iterator = fromStreamSource(nextSource)[Symbol.iterator]();
this.iterator = streamSourceHelpers
.fromStreamSource(nextSource)
[Symbol.iterator]();
}

@@ -672,6 +676,7 @@

readonly f: (...args: [...T, ...A]) => R,
readonly args: A
readonly args: A,
streamSourceHelpers: StreamSourceHelpers
) {
super();
this.iter = fromStreamSource(source)[Symbol.iterator]();
this.iter = streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
}

@@ -699,6 +704,7 @@

readonly args: A,
readonly invert: boolean
readonly invert: boolean,
streamSourceHelpers: StreamSourceHelpers
) {
super();
this.iter = fromStreamSource(source)[Symbol.iterator]();
this.iter = streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]();
}

@@ -837,3 +843,4 @@

readonly iterables: { [K in keyof I]: StreamSource<I[K]> },
readonly zipFun: (...values: I) => R
readonly zipFun: (...values: I) => R,
streamSourceHelpers: StreamSourceHelpers
) {

@@ -843,3 +850,4 @@ super();

this.sources = iterables.map(
(source): FastIterator<any> => fromStreamSource(source)[Symbol.iterator]()
(source): FastIterator<any> =>
streamSourceHelpers.fromStreamSource(source)[Symbol.iterator]()
);

@@ -878,3 +886,4 @@ }

readonly iters: { [K in keyof I]: StreamSource<I[K]> },
readonly zipFun: (...values: { [K in keyof I]: I[K] | F }) => R
readonly zipFun: (...values: { [K in keyof I]: I[K] | F }) => R,
streamSourceHelpers: StreamSourceHelpers
) {

@@ -884,3 +893,4 @@ super();

this.sources = iters.map(
(o): FastIterator<any> => fromStreamSource(o)[Symbol.iterator]()
(o): FastIterator<any> =>
streamSourceHelpers.fromStreamSource(o)[Symbol.iterator]()
);

@@ -887,0 +897,0 @@ }

@@ -0,1 +1,2 @@

import { RimbuError, Token } from '@rimbu/base';
import {

@@ -22,42 +23,41 @@ ArrayNonEmpty,

import {
isFastIterator,
emptyFastIterator,
FlatMapIterator,
AlwaysIterator,
AppendIterator,
ArrayIterator,
ArrayReverseIterator,
CollectIterator,
ConcatIterator,
DistinctPreviousIterator,
DropIterator,
DropWhileIterator,
FilterApplyIterator,
FilterIterator,
FilterPureIterator,
FlatMapIterator,
IndexedIterator,
IndicesOfIterator,
IndicesWhereIterator,
IndicesOfIterator,
TakeWhileIterator,
DropWhileIterator,
TakeIterator,
DropIterator,
IntersperseIterator,
SplitWhereIterator,
SplitOnIterator,
ReduceIterator,
ReduceAllIterator,
RepeatIterator,
CollectIterator,
ArrayIterator,
ArrayReverseIterator,
AlwaysIterator,
MapApplyIterator,
FilterApplyIterator,
MapIterator,
MapPureIterator,
PrependIterator,
RandomIntIterator,
RandomIterator,
RangeDownIterator,
RangeUpIterator,
RandomIntIterator,
RandomIterator,
ReduceAllIterator,
ReduceIterator,
RepeatIterator,
SplitOnIterator,
SplitWhereIterator,
TakeIterator,
TakeWhileIterator,
UnfoldIterator,
WindowIterator,
ZipAllWithItererator,
ZipWithIterator,
AppendIterator,
IndexedIterator,
MapIterator,
MapPureIterator,
PrependIterator,
DistinctPreviousIterator,
WindowIterator,
emptyFastIterator,
isFastIterator,
} from '@rimbu/stream/custom';
import { RimbuError, Token } from '@rimbu/base';

@@ -862,3 +862,7 @@ function* yieldObjKeys<K extends string | number | symbol>(

[Symbol.iterator](): FastIterator<T2> {
return new FlatMapIterator<T, T2>(this.source, this.flatmapFun);
return new FlatMapIterator<T, T2>(
this.source,
this.flatmapFun,
streamSourceHelpers
);
}

@@ -876,3 +880,7 @@ }

[Symbol.iterator](): FastIterator<T> {
return new ConcatIterator<T>(this.source, this.otherSources);
return new ConcatIterator<T>(
this.source,
this.otherSources,
streamSourceHelpers
);
}

@@ -1734,3 +1742,8 @@

[Symbol.iterator](): FastIterator<R> {
return new MapApplyIterator(this.source, this.f, this.args);
return new MapApplyIterator(
this.source,
this.f,
this.args,
streamSourceHelpers
);
}

@@ -1757,3 +1770,4 @@ }

this.args,
this.invert
this.invert,
streamSourceHelpers
);

@@ -1857,2 +1871,9 @@ }

const streamSourceHelpers = {
fromStreamSource,
isEmptyStreamSourceInstance,
};
export type StreamSourceHelpers = typeof streamSourceHelpers;
export const StreamConstructorsImpl: StreamConstructors =

@@ -2008,3 +2029,3 @@ Object.freeze<StreamConstructors>({

return new FromStream(
() => new ZipWithIterator(sources as any, zipFun)
() => new ZipWithIterator(sources as any, zipFun, streamSourceHelpers)
);

@@ -2024,3 +2045,8 @@ };

(): FastIterator<any> =>
new ZipAllWithItererator(fillValue, sources, zipFun)
new ZipAllWithItererator(
fillValue,
sources,
zipFun,
streamSourceHelpers
)
);

@@ -2027,0 +2053,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc