Socket
Socket
Sign inDemoInstall

@rimbu/stream

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rimbu/stream - npm Package Compare versions

Comparing version 0.10.1 to 0.10.2

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

23

dist/main/async-custom/constructors.js

@@ -7,5 +7,4 @@ "use strict";

var common_1 = require("@rimbu/common");
var stream_1 = require("@rimbu/stream");
var async_1 = require("@rimbu/stream/async");
var async_custom_1 = require("@rimbu/stream/async-custom");
var custom_1 = require("@rimbu/stream/custom");
var AsyncOfIterator = /** @class */ (function (_super) {

@@ -48,3 +47,3 @@ (0, tslib_1.__extends)(AsyncOfIterator, _super);

return source;
if (async_1.AsyncStreamSource.isEmptyInstance(source))
if ((0, async_custom_1.isEmptyAsyncStreamSourceInstance)(source))
return exports.AsyncStreamConstructorsImpl.empty();

@@ -59,3 +58,3 @@ return new FromSource(source);

AsyncEmptyStream.prototype[Symbol.asyncIterator] = function () {
return async_1.AsyncFastIterator.emptyAsyncFastIterator;
return async_custom_1.emptyAsyncFastIterator;
};

@@ -193,3 +192,3 @@ AsyncEmptyStream.prototype.assumeNonEmpty = function () {

}
if (others.every(async_1.AsyncStreamSource.isEmptyInstance))
if (others.every(async_custom_1.isEmptyAsyncStreamSourceInstance))
return this;

@@ -386,4 +385,4 @@ var _a = (0, tslib_1.__read)(others), source1 = _a[0], source2 = _a[1], sources = _a.slice(2);

}
if (async_1.AsyncStreamSource.isEmptyInstance(source)) {
return async_1.AsyncFastIterator.emptyAsyncFastIterator;
if ((0, async_custom_1.isEmptyAsyncStreamSourceInstance)(source)) {
return async_custom_1.emptyAsyncFastIterator;
}

@@ -396,3 +395,3 @@ if (typeof source === 'string') {

var iterator = source[Symbol.asyncIterator]();
if (async_1.AsyncFastIterator.isAsyncFastIterator(iterator)) {
if ((0, async_custom_1.isAsyncFastIterator)(iterator)) {
if (undefined === close) {

@@ -664,3 +663,3 @@ return iterator;

return function (zipFun) {
if (sources.some(async_1.AsyncStreamSource.isEmptyInstance)) {
if (sources.some(async_custom_1.isEmptyAsyncStreamSourceInstance)) {
return exports.AsyncStreamConstructorsImpl.empty();

@@ -684,3 +683,3 @@ }

return function (fillValue, zipFun) {
if (sources.every(async_1.AsyncStreamSource.isEmptyInstance)) {
if (sources.every(async_custom_1.isEmptyAsyncStreamSourceInstance)) {
return exports.AsyncStreamConstructorsImpl.empty();

@@ -704,4 +703,4 @@ }

unzip: function (source, length) {
if (async_1.AsyncStreamSource.isEmptyInstance(source)) {
return stream_1.Stream.of(exports.AsyncStreamConstructorsImpl.empty())
if ((0, async_custom_1.isEmptyAsyncStreamSourceInstance)(source)) {
return custom_1.StreamConstructorsImpl.of(exports.AsyncStreamConstructorsImpl.empty())
.repeat(length)

@@ -708,0 +707,0 @@ .toArray();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./async-fast-iterator-base"), exports);
(0, tslib_1.__exportStar)(require("./async-stream-source-base"), exports);
(0, tslib_1.__exportStar)(require("./async-stream-custom"), exports);

@@ -5,0 +7,0 @@ (0, tslib_1.__exportStar)(require("./constructors"), exports);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncFastIterator = void 0;
var common_1 = require("@rimbu/common");
var AsyncFastIterator;
(function (AsyncFastIterator) {
AsyncFastIterator.fixedDone = Promise.resolve({
done: true,
value: undefined,
});
function isAsyncFastIterator(iterator) {
return "fastNext" in iterator;
}
AsyncFastIterator.isAsyncFastIterator = isAsyncFastIterator;
AsyncFastIterator.emptyAsyncFastIterator = {
fastNext: function (otherwise) {
return common_1.AsyncOptLazy.toMaybePromise(otherwise);
},
next: function () {
return AsyncFastIterator.fixedDone;
},
};
})(AsyncFastIterator = exports.AsyncFastIterator || (exports.AsyncFastIterator = {}));
//# sourceMappingURL=async-fast-iterator.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncStreamSource = void 0;
var stream_1 = require("@rimbu/stream");
var async_1 = require("@rimbu/stream/async");
var AsyncStreamSource;
(function (AsyncStreamSource) {
function isEmptyInstance(source) {
return (source === async_1.AsyncStream.empty() ||
stream_1.StreamSource.isEmptyInstance(source));
}
AsyncStreamSource.isEmptyInstance = isEmptyInstance;
})(AsyncStreamSource = exports.AsyncStreamSource || (exports.AsyncStreamSource = {}));
//# sourceMappingURL=async-stream-source.js.map

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

var common_1 = require("@rimbu/common");
var stream_1 = require("@rimbu/stream");
var custom_1 = require("@rimbu/stream/custom");

@@ -16,3 +15,3 @@ var EmptyStream = /** @class */ (function (_super) {

EmptyStream.prototype[Symbol.iterator] = function () {
return stream_1.FastIterator.emptyFastIterator;
return custom_1.emptyFastIterator;
};

@@ -117,3 +116,3 @@ EmptyStream.prototype.assumeNonEmpty = function () {

}
if (others.every(stream_1.StreamSource.isEmptyInstance))
if (others.every(custom_1.isEmptyStreamSourceInstance))
return this;

@@ -185,3 +184,3 @@ var _a = (0, tslib_1.__read)(others), source1 = _a[0], source2 = _a[1], sources = _a.slice(2);

var fromStreamSource = function (source) {
if (undefined === source || stream_1.StreamSource.isEmptyInstance(source))
if (undefined === source || (0, custom_1.isEmptyStreamSourceInstance)(source))
return exports.StreamConstructorsImpl.empty();

@@ -888,3 +887,3 @@ if (isStream(source))

return function (zipFun) {
if (sources.some(stream_1.StreamSource.isEmptyInstance)) {
if (sources.some(custom_1.isEmptyStreamSourceInstance)) {
return exports.StreamConstructorsImpl.empty();

@@ -908,3 +907,3 @@ }

return function (fillValue, zipFun) {
if (sources.every(stream_1.StreamSource.isEmptyInstance)) {
if (sources.every(custom_1.isEmptyStreamSourceInstance)) {
return exports.StreamConstructorsImpl.empty();

@@ -928,3 +927,3 @@ }

unzip: function (source, length) {
if (stream_1.StreamSource.isEmptyInstance(source)) {
if ((0, custom_1.isEmptyStreamSourceInstance)(source)) {
return exports.StreamConstructorsImpl.of(exports.StreamConstructorsImpl.empty())

@@ -931,0 +930,0 @@ .repeat(length)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("./fast-iterator-custom"), exports);
(0, tslib_1.__exportStar)(require("./stream-source-base"), exports);
(0, tslib_1.__exportStar)(require("./stream-custom"), exports);
(0, tslib_1.__exportStar)(require("./constructors"), exports);
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ "use strict";

var common_1 = require("@rimbu/common");
var stream_1 = require("@rimbu/stream");
var custom_1 = require("@rimbu/stream/custom");
/**

@@ -19,3 +19,3 @@ * A base class for `FastIterator` instances, that takes implements the default `next`

if (done === value)
return stream_1.FastIterator.fixedDone;
return custom_1.fixedDoneIteratorResult;
return { value: value, done: false };

@@ -35,3 +35,3 @@ };

var it1 = this[Symbol.iterator]();
var it2 = stream_1.Stream.from(other)[Symbol.iterator]();
var it2 = custom_1.StreamConstructorsImpl.from(other)[Symbol.iterator]();
var done = Symbol('Done');

@@ -102,6 +102,3 @@ while (true) {

return this.flatMap(function (value, index, halt) {
return stream_1.Stream.from(flatMapFun(value, index, halt)).map(function (result) { return [
value,
result,
]; });
return custom_1.StreamConstructorsImpl.from(flatMapFun(value, index, halt)).map(function (result) { return [value, result]; });
});

@@ -282,3 +279,3 @@ };

if (amount <= 0)
return stream_1.Stream.empty();
return custom_1.StreamConstructorsImpl.empty();
return new TakeStream(this, amount);

@@ -302,3 +299,3 @@ };

}
if (others.every(stream_1.StreamSource.isEmptyInstance)) {
if (others.every(custom_1.isEmptyStreamSourceInstance)) {
return this.assumeNonEmpty();

@@ -341,5 +338,5 @@ }

StreamBase.prototype.intersperse = function (sep) {
if (stream_1.StreamSource.isEmptyInstance(sep))
if ((0, custom_1.isEmptyStreamSourceInstance)(sep))
return this;
var sepStream = stream_1.Stream.from(sep);
var sepStream = custom_1.StreamConstructorsImpl.from(sep);
return new IntersperseStream(this, sepStream);

@@ -364,4 +361,4 @@ };

StreamBase.prototype.mkGroup = function (_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.sep, sep = _c === void 0 ? stream_1.Stream.empty() : _c, _d = _b.start, start = _d === void 0 ? stream_1.Stream.empty() : _d, _e = _b.end, end = _e === void 0 ? stream_1.Stream.empty() : _e;
return stream_1.Stream.from(start, this.intersperse(sep), end);
var _b = _a === void 0 ? {} : _a, _c = _b.sep, sep = _c === void 0 ? custom_1.StreamConstructorsImpl.empty() : _c, _d = _b.start, start = _d === void 0 ? custom_1.StreamConstructorsImpl.empty() : _d, _e = _b.end, end = _e === void 0 ? custom_1.StreamConstructorsImpl.empty() : _e;
return custom_1.StreamConstructorsImpl.from(start, this.intersperse(sep), end);
};

@@ -754,3 +751,4 @@ StreamBase.prototype.splitWhere = function (pred) {

var nextSource = this.flatMapFun(nextIter, state.nextIndex(), state.halt);
this.currentIterator = stream_1.Stream.from(nextSource)[Symbol.iterator]();
this.currentIterator =
custom_1.StreamConstructorsImpl.from(nextSource)[Symbol.iterator]();
}

@@ -792,3 +790,3 @@ return nextValue;

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

@@ -798,3 +796,4 @@ return (0, common_1.OptLazy)(otherwise);

}
this.iterator = stream_1.Stream.from(nextSource)[Symbol.iterator]();
this.iterator =
custom_1.StreamConstructorsImpl.from(nextSource)[Symbol.iterator]();
}

@@ -826,4 +825,4 @@ return value;

var source = sources[sourceIndex];
if (!stream_1.StreamSource.isEmptyInstance(source)) {
stream_1.Stream.from(source).forEach(f, state);
if (!(0, custom_1.isEmptyStreamSourceInstance)(source)) {
custom_1.StreamConstructorsImpl.from(source).forEach(f, state);
}

@@ -837,5 +836,5 @@ }

var source = sources[sourceIndex];
if (!stream_1.StreamSource.isEmptyInstance(source)) {
if (!(0, custom_1.isEmptyStreamSourceInstance)(source)) {
var done = Symbol('Done');
var value = stream_1.Stream.from(source).last(done);
var value = custom_1.StreamConstructorsImpl.from(source).last(done);
if (done !== value)

@@ -854,4 +853,4 @@ return value;

var source = sources[sourceIndex];
if (!stream_1.StreamSource.isEmptyInstance(source)) {
result += stream_1.Stream.from(source).count();
if (!(0, custom_1.isEmptyStreamSourceInstance)(source)) {
result += custom_1.StreamConstructorsImpl.from(source).count();
}

@@ -875,4 +874,4 @@ }

var source = sources[sourceIndex];
if (!stream_1.StreamSource.isEmptyInstance(source)) {
result = result.concat(stream_1.Stream.from(source).toArray());
if (!(0, custom_1.isEmptyStreamSourceInstance)(source)) {
result = result.concat(custom_1.StreamConstructorsImpl.from(source).toArray());
}

@@ -1545,3 +1544,3 @@ }

var iterator = this.iterable[Symbol.iterator]();
if (stream_1.FastIterator.isFastIterator(iterator))
if ((0, custom_1.isFastIterator)(iterator))
return iterator;

@@ -1548,0 +1547,0 @@ return new SlowIteratorAdapter(iterator);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FastIterator = void 0;
var common_1 = require("@rimbu/common");
var _fixedDone = {
done: true,
value: undefined,
};
var FastIterator;
(function (FastIterator) {
FastIterator.fixedDone = _fixedDone;
FastIterator.emptyFastIterator = {
fastNext: function (otherwise) {
return (0, common_1.OptLazy)(otherwise);
},
next: function () {
return _fixedDone;
},
};
function isFastIterator(iterator) {
return "fastNext" in iterator;
}
FastIterator.isFastIterator = isFastIterator;
})(FastIterator = exports.FastIterator || (exports.FastIterator = {}));
//# sourceMappingURL=fast-iterator.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamSource = void 0;
var stream_1 = require("@rimbu/stream");
var StreamSource;
(function (StreamSource) {
/**
* Returns true if the given `source` StreamSource is known to be empty.
* @param source - a StreamSource
* @note
* If this function returns false, it does not guarantee that the Stream is not empty. It only
* means that it is not known if it is empty.
*/
function isEmptyInstance(source) {
if (source === '')
return true;
if (typeof source === 'object') {
if (source === stream_1.Stream.empty())
return true;
if ("length" in source && source.length === 0)
return true;
if ("size" in source && source.size === 0)
return true;
if ("isEmpty" in source && source.isEmpty === true)
return true;
}
return false;
}
StreamSource.isEmptyInstance = isEmptyInstance;
})(StreamSource = exports.StreamSource || (exports.StreamSource = {}));
//# sourceMappingURL=stream-source.js.map
import { __awaiter } from "tslib";
import { AsyncOptLazy, CollectFun, Comp, Eq, TraverseState, } from '@rimbu/common';
import { AsyncFastIterator, AsyncStream, AsyncStreamSource, } from '@rimbu/stream/async';
import { closeIters } from '@rimbu/stream/async-custom';
import { closeIters, isEmptyAsyncStreamSourceInstance, fixedDoneAsyncIteratorResult, AsyncStreamConstructorsImpl, } from '@rimbu/stream/async-custom';
export class AsyncFastIteratorBase {

@@ -11,3 +10,3 @@ next() {

if (done === value)
return AsyncFastIterator.fixedDone;
return fixedDoneAsyncIteratorResult;
return { value, done: false };

@@ -24,3 +23,3 @@ });

const it1 = this[Symbol.asyncIterator]();
const it2 = AsyncStream.from(other)[Symbol.asyncIterator]();
const it2 = AsyncStreamConstructorsImpl.from(other)[Symbol.asyncIterator]();
const done = Symbol('Done');

@@ -353,3 +352,3 @@ while (true) {

if (amount <= 0)
return AsyncStream.empty();
return AsyncStreamConstructorsImpl.empty();
return new AsyncTakeStream(this, amount);

@@ -369,3 +368,3 @@ }

concat(...others) {
if (others.every(AsyncStreamSource.isEmptyInstance))
if (others.every(isEmptyAsyncStreamSourceInstance))
return this;

@@ -425,5 +424,5 @@ return new AsyncConcatStream(this, others);

intersperse(sep) {
if (AsyncStreamSource.isEmptyInstance(sep))
if (isEmptyAsyncStreamSourceInstance(sep))
return this;
const sepStream = AsyncStream.from(sep);
const sepStream = AsyncStreamConstructorsImpl.from(sep);
return new AsyncIntersperseStream(this, sepStream);

@@ -454,4 +453,4 @@ }

}
mkGroup({ sep = AsyncStream.empty(), start = AsyncStream.empty(), end = AsyncStream.empty(), } = {}) {
return AsyncStream.from(start, this.intersperse(sep), end);
mkGroup({ sep = AsyncStreamConstructorsImpl.empty(), start = AsyncStreamConstructorsImpl.empty(), end = AsyncStreamConstructorsImpl.empty(), } = {}) {
return AsyncStreamConstructorsImpl.from(start, this.intersperse(sep), end);
}

@@ -886,3 +885,3 @@ splitWhere(pred) {

const nextSource = this.flatMapFun(nextIter, state.nextIndex(), state.halt);
const currentIterator = AsyncStream.from(nextSource)[Symbol.asyncIterator]();
const currentIterator = AsyncStreamConstructorsImpl.from(nextSource)[Symbol.asyncIterator]();
this.currentIterator = currentIterator;

@@ -913,3 +912,3 @@ }

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

@@ -920,3 +919,4 @@ return AsyncOptLazy.toMaybePromise(otherwise);

}
this.iterator = AsyncStream.from(nextSource)[Symbol.asyncIterator]();
this.iterator =
AsyncStreamConstructorsImpl.from(nextSource)[Symbol.asyncIterator]();
}

@@ -923,0 +923,0 @@ return value;

import { __awaiter } from "tslib";
import { RimbuError, Token } from '@rimbu/base';
import { AsyncOptLazy, Reducer, } from '@rimbu/common';
import { Stream } from '@rimbu/stream';
import { AsyncFastIterator, AsyncStreamSource } from '@rimbu/stream/async';
import { AsyncFastIteratorBase, AsyncFromStream, AsyncStreamBase, closeIters, } from '@rimbu/stream/async-custom';
import { AsyncFastIteratorBase, AsyncFromStream, AsyncStreamBase, closeIters, emptyAsyncFastIterator, isAsyncFastIterator, isEmptyAsyncStreamSourceInstance, } from '@rimbu/stream/async-custom';
import { StreamConstructorsImpl } from '@rimbu/stream/custom';
class AsyncOfIterator extends AsyncFastIteratorBase {

@@ -38,3 +37,3 @@ constructor(values) {

return source;
if (AsyncStreamSource.isEmptyInstance(source))
if (isEmptyAsyncStreamSourceInstance(source))
return AsyncStreamConstructorsImpl.empty();

@@ -45,3 +44,3 @@ return new FromSource(source);

[Symbol.asyncIterator]() {
return AsyncFastIterator.emptyAsyncFastIterator;
return emptyAsyncFastIterator;
}

@@ -157,3 +156,3 @@ assumeNonEmpty() {

concat(...others) {
if (others.every(AsyncStreamSource.isEmptyInstance))
if (others.every(isEmptyAsyncStreamSourceInstance))
return this;

@@ -292,4 +291,4 @@ const [source1, source2, ...sources] = others;

}
if (AsyncStreamSource.isEmptyInstance(source)) {
return AsyncFastIterator.emptyAsyncFastIterator;
if (isEmptyAsyncStreamSourceInstance(source)) {
return emptyAsyncFastIterator;
}

@@ -302,3 +301,3 @@ if (typeof source === 'string') {

const iterator = source[Symbol.asyncIterator]();
if (AsyncFastIterator.isAsyncFastIterator(iterator)) {
if (isAsyncFastIterator(iterator)) {
if (undefined === close) {

@@ -476,3 +475,3 @@ return iterator;

return (zipFun) => {
if (sources.some(AsyncStreamSource.isEmptyInstance)) {
if (sources.some(isEmptyAsyncStreamSourceInstance)) {
return AsyncStreamConstructorsImpl.empty();

@@ -488,3 +487,3 @@ }

return (fillValue, zipFun) => {
if (sources.every(AsyncStreamSource.isEmptyInstance)) {
if (sources.every(isEmptyAsyncStreamSourceInstance)) {
return AsyncStreamConstructorsImpl.empty();

@@ -502,4 +501,4 @@ }

unzip(source, length) {
if (AsyncStreamSource.isEmptyInstance(source)) {
return Stream.of(AsyncStreamConstructorsImpl.empty())
if (isEmptyAsyncStreamSourceInstance(source)) {
return StreamConstructorsImpl.of(AsyncStreamConstructorsImpl.empty())
.repeat(length)

@@ -506,0 +505,0 @@ .toArray();

@@ -0,1 +1,3 @@

export * from './async-fast-iterator-base';
export * from './async-stream-source-base';
export * from './async-stream-custom';

@@ -2,0 +4,0 @@ export * from './constructors';

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

import { AsyncOptLazy } from '@rimbu/common';
export var AsyncFastIterator;
(function (AsyncFastIterator) {
AsyncFastIterator.fixedDone = Promise.resolve({
done: true,
value: undefined,
});
function isAsyncFastIterator(iterator) {
return `fastNext` in iterator;
}
AsyncFastIterator.isAsyncFastIterator = isAsyncFastIterator;
AsyncFastIterator.emptyAsyncFastIterator = {
fastNext(otherwise) {
return AsyncOptLazy.toMaybePromise(otherwise);
},
next() {
return AsyncFastIterator.fixedDone;
},
};
})(AsyncFastIterator || (AsyncFastIterator = {}));
export {};
//# sourceMappingURL=async-fast-iterator.js.map

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

import { StreamSource } from '@rimbu/stream';
import { AsyncStream } from '@rimbu/stream/async';
export var AsyncStreamSource;
(function (AsyncStreamSource) {
function isEmptyInstance(source) {
return (source === AsyncStream.empty() ||
StreamSource.isEmptyInstance(source));
}
AsyncStreamSource.isEmptyInstance = isEmptyInstance;
})(AsyncStreamSource || (AsyncStreamSource = {}));
export {};
//# sourceMappingURL=async-stream-source.js.map
import { RimbuError, Token } from '@rimbu/base';
import { ErrBase, IndexRange, OptLazy, Range, Reducer, TraverseState, } from '@rimbu/common';
import { FastIterator, StreamSource } from '@rimbu/stream';
import { FastIteratorBase, FromIterable, FromStream, StreamBase, } from '@rimbu/stream/custom';
import { emptyFastIterator, FastIteratorBase, FromIterable, FromStream, StreamBase, isEmptyStreamSourceInstance, } from '@rimbu/stream/custom';
class EmptyStream extends StreamBase {
[Symbol.iterator]() {
return FastIterator.emptyFastIterator;
return emptyFastIterator;
}

@@ -103,3 +102,3 @@ assumeNonEmpty() {

concat(...others) {
if (others.every(StreamSource.isEmptyInstance))
if (others.every(isEmptyStreamSourceInstance))
return this;

@@ -164,3 +163,3 @@ const [source1, source2, ...sources] = others;

const fromStreamSource = (source) => {
if (undefined === source || StreamSource.isEmptyInstance(source))
if (undefined === source || isEmptyStreamSourceInstance(source))
return StreamConstructorsImpl.empty();

@@ -769,3 +768,3 @@ if (isStream(source))

return (zipFun) => {
if (sources.some(StreamSource.isEmptyInstance)) {
if (sources.some(isEmptyStreamSourceInstance)) {
return StreamConstructorsImpl.empty();

@@ -781,3 +780,3 @@ }

return (fillValue, zipFun) => {
if (sources.every(StreamSource.isEmptyInstance)) {
if (sources.every(isEmptyStreamSourceInstance)) {
return StreamConstructorsImpl.empty();

@@ -795,3 +794,3 @@ }

unzip(source, length) {
if (StreamSource.isEmptyInstance(source)) {
if (isEmptyStreamSourceInstance(source)) {
return StreamConstructorsImpl.of(StreamConstructorsImpl.empty())

@@ -798,0 +797,0 @@ .repeat(length)

@@ -0,3 +1,5 @@

export * from './fast-iterator-custom';
export * from './stream-source-base';
export * from './stream-custom';
export * from './constructors';
//# sourceMappingURL=index.js.map
import { CollectFun, Comp, Eq, OptLazy, Reducer, TraverseState, } from '@rimbu/common';
import { FastIterator, Stream, StreamSource } from '@rimbu/stream';
import { fixedDoneIteratorResult, isEmptyStreamSourceInstance, isFastIterator, StreamConstructorsImpl, } from '@rimbu/stream/custom';
/**

@@ -12,3 +12,3 @@ * A base class for `FastIterator` instances, that takes implements the default `next`

if (done === value)
return FastIterator.fixedDone;
return fixedDoneIteratorResult;
return { value, done: false };

@@ -23,3 +23,3 @@ }

const it1 = this[Symbol.iterator]();
const it2 = Stream.from(other)[Symbol.iterator]();
const it2 = StreamConstructorsImpl.from(other)[Symbol.iterator]();
const done = Symbol('Done');

@@ -79,6 +79,3 @@ while (true) {

flatZip(flatMapFun) {
return this.flatMap((value, index, halt) => Stream.from(flatMapFun(value, index, halt)).map((result) => [
value,
result,
]));
return this.flatMap((value, index, halt) => StreamConstructorsImpl.from(flatMapFun(value, index, halt)).map((result) => [value, result]));
}

@@ -242,3 +239,3 @@ filter(pred) {

if (amount <= 0)
return Stream.empty();
return StreamConstructorsImpl.empty();
return new TakeStream(this, amount);

@@ -257,3 +254,3 @@ }

concat(...others) {
if (others.every(StreamSource.isEmptyInstance)) {
if (others.every(isEmptyStreamSourceInstance)) {
return this.assumeNonEmpty();

@@ -296,5 +293,5 @@ }

intersperse(sep) {
if (StreamSource.isEmptyInstance(sep))
if (isEmptyStreamSourceInstance(sep))
return this;
const sepStream = Stream.from(sep);
const sepStream = StreamConstructorsImpl.from(sep);
return new IntersperseStream(this, sepStream);

@@ -317,4 +314,4 @@ }

}
mkGroup({ sep = Stream.empty(), start = Stream.empty(), end = Stream.empty(), } = {}) {
return Stream.from(start, this.intersperse(sep), end);
mkGroup({ sep = StreamConstructorsImpl.empty(), start = StreamConstructorsImpl.empty(), end = StreamConstructorsImpl.empty(), } = {}) {
return StreamConstructorsImpl.from(start, this.intersperse(sep), end);
}

@@ -652,3 +649,4 @@ splitWhere(pred) {

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

@@ -684,3 +682,3 @@ return nextValue;

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

@@ -690,3 +688,4 @@ return OptLazy(otherwise);

}
this.iterator = Stream.from(nextSource)[Symbol.iterator]();
this.iterator =
StreamConstructorsImpl.from(nextSource)[Symbol.iterator]();
}

@@ -714,4 +713,4 @@ return value;

const source = sources[sourceIndex];
if (!StreamSource.isEmptyInstance(source)) {
Stream.from(source).forEach(f, state);
if (!isEmptyStreamSourceInstance(source)) {
StreamConstructorsImpl.from(source).forEach(f, state);
}

@@ -725,5 +724,5 @@ }

const source = sources[sourceIndex];
if (!StreamSource.isEmptyInstance(source)) {
if (!isEmptyStreamSourceInstance(source)) {
const done = Symbol('Done');
const value = Stream.from(source).last(done);
const value = StreamConstructorsImpl.from(source).last(done);
if (done !== value)

@@ -742,4 +741,4 @@ return value;

const source = sources[sourceIndex];
if (!StreamSource.isEmptyInstance(source)) {
result += Stream.from(source).count();
if (!isEmptyStreamSourceInstance(source)) {
result += StreamConstructorsImpl.from(source).count();
}

@@ -759,4 +758,4 @@ }

const source = sources[sourceIndex];
if (!StreamSource.isEmptyInstance(source)) {
result = result.concat(Stream.from(source).toArray());
if (!isEmptyStreamSourceInstance(source)) {
result = result.concat(StreamConstructorsImpl.from(source).toArray());
}

@@ -1333,3 +1332,3 @@ }

const iterator = this.iterable[Symbol.iterator]();
if (FastIterator.isFastIterator(iterator))
if (isFastIterator(iterator))
return iterator;

@@ -1336,0 +1335,0 @@ return new SlowIteratorAdapter(iterator);

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

import { OptLazy } from '@rimbu/common';
const _fixedDone = {
done: true,
value: undefined,
};
export var FastIterator;
(function (FastIterator) {
FastIterator.fixedDone = _fixedDone;
FastIterator.emptyFastIterator = {
fastNext(otherwise) {
return OptLazy(otherwise);
},
next() {
return _fixedDone;
},
};
function isFastIterator(iterator) {
return `fastNext` in iterator;
}
FastIterator.isFastIterator = isFastIterator;
})(FastIterator || (FastIterator = {}));
export {};
//# sourceMappingURL=fast-iterator.js.map

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

import { Stream } from '@rimbu/stream';
export var StreamSource;
(function (StreamSource) {
/**
* Returns true if the given `source` StreamSource is known to be empty.
* @param source - a StreamSource
* @note
* If this function returns false, it does not guarantee that the Stream is not empty. It only
* means that it is not known if it is empty.
*/
function isEmptyInstance(source) {
if (source === '')
return true;
if (typeof source === 'object') {
if (source === Stream.empty())
return true;
if (`length` in source && source.length === 0)
return true;
if (`size` in source && source.size === 0)
return true;
if (`isEmpty` in source && source.isEmpty === true)
return true;
}
return false;
}
StreamSource.isEmptyInstance = isEmptyInstance;
})(StreamSource || (StreamSource = {}));
export {};
//# sourceMappingURL=stream-source.js.map
import { ArrayNonEmpty, AsyncCollectFun, AsyncOptLazy, AsyncReducer, Eq, MaybePromise, ToJSON, TraverseState } from '@rimbu/common';
import { AsyncFastIterator, AsyncStream, AsyncStreamSource } from '@rimbu/stream/async';
import type { AsyncFastIterator, AsyncStream, AsyncStreamSource } from '@rimbu/stream/async';
export declare abstract class AsyncFastIteratorBase<T> implements AsyncFastIterator<T> {

@@ -4,0 +4,0 @@ abstract fastNext<O>(otherwise?: AsyncOptLazy<O>): MaybePromise<T | O>;

import { Token } from '@rimbu/base';
import { ArrayNonEmpty, AsyncOptLazy, MaybePromise } from '@rimbu/common';
import type { AsyncStream } from '@rimbu/stream/async';
import { AsyncStreamSource } from '@rimbu/stream/async';
import type { AsyncStreamSource } from '@rimbu/stream/async';
export interface AsyncStreamConstructors {

@@ -6,0 +6,0 @@ of<T>(...values: ArrayNonEmpty<AsyncOptLazy<T>>): AsyncStream.NonEmpty<T>;

@@ -0,3 +1,5 @@

export * from './async-fast-iterator-base';
export * from './async-stream-source-base';
export * from './async-stream-custom';
export * from './constructors';
export * from './utils';

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

import { AsyncOptLazy, MaybePromise } from '@rimbu/common';
import type { AsyncOptLazy, MaybePromise } from '@rimbu/common';
export interface AsyncFastIterator<T> extends AsyncIterator<T> {

@@ -7,6 +7,1 @@ fastNext(): MaybePromise<T | undefined>;

}
export declare namespace AsyncFastIterator {
const fixedDone: Promise<IteratorReturnResult<any> | IteratorYieldResult<any>>;
function isAsyncFastIterator<T>(iterator: AsyncIterator<T>): iterator is AsyncFastIterator<T>;
const emptyAsyncFastIterator: AsyncFastIterator<any>;
}
import type { MaybePromise } from '@rimbu/common';
import { StreamSource } from '@rimbu/stream';
import { AsyncStream, AsyncStreamable } from '@rimbu/stream/async';
import type { StreamSource } from '@rimbu/stream';
import type { AsyncStream, AsyncStreamable } from '@rimbu/stream/async';
export declare type AsyncStreamSource<T> = undefined | AsyncStreamSource.NonEmpty<T> | AsyncStream<T> | (() => MaybePromise<AsyncStreamSource<T>>) | AsyncStreamable<T> | StreamSource<T> | AsyncIterable<T>;
export declare namespace AsyncStreamSource {
type NonEmpty<T> = AsyncStream.NonEmpty<T> | AsyncStreamable.NonEmpty<T> | StreamSource.NonEmpty<T> | (() => MaybePromise<AsyncStreamSource.NonEmpty<T>>);
function isEmptyInstance(source: AsyncStreamSource<any>): boolean;
}
import { Token } from '@rimbu/base';
import { ArrayNonEmpty, IndexRange, OptLazy, StringNonEmpty } from '@rimbu/common';
import type { Stream } from '@rimbu/stream';
import { StreamSource } from '@rimbu/stream';
import type { Stream, StreamSource } from '@rimbu/stream';
export interface StreamConstructors {

@@ -6,0 +5,0 @@ /**

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

export * from './fast-iterator-custom';
export * from './stream-source-base';
export * from './stream-custom';
export * from './constructors';
import { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common';
import { FastIterator, Stream, StreamSource } from '@rimbu/stream';
import type { FastIterator, Stream, StreamSource } from '@rimbu/stream';
/**

@@ -4,0 +4,0 @@ * A base class for `FastIterator` instances, that takes implements the default `next`

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

import { OptLazy } from '@rimbu/common';
import type { OptLazy } from '@rimbu/common';
/**

@@ -18,6 +18,1 @@ * An iterator that extends the default `Iterator` interface with methods that give more performance.

}
export declare namespace FastIterator {
const fixedDone: IteratorResult<any>;
const emptyFastIterator: FastIterator<any>;
function isFastIterator<T>(iterator: Iterator<T>): iterator is FastIterator<T>;
}

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

import { Stream, Streamable } from '@rimbu/stream';
import type { Stream, Streamable } from '@rimbu/stream';
/**

@@ -13,10 +13,2 @@ * Any object that is Iterable, a Stream, or can produce a Stream.

type NonEmpty<T> = Stream.NonEmpty<T> | Streamable.NonEmpty<T> | readonly [T, ...T[]];
/**
* Returns true if the given `source` StreamSource is known to be empty.
* @param source - a StreamSource
* @note
* If this function returns false, it does not guarantee that the Stream is not empty. It only
* means that it is not known if it is empty.
*/
function isEmptyInstance(source: StreamSource<unknown>): boolean;
}
{
"name": "@rimbu/stream",
"version": "0.10.1",
"version": "0.10.2",
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript",

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

},
"gitHead": "0474974142d1aa81cc6d9e746010bcd6dba60265"
"gitHead": "7271174e99229284224cef3489d3e80bddb305d0"
}

@@ -13,3 +13,3 @@ import {

} from '@rimbu/common';
import {
import type {
AsyncFastIterator,

@@ -19,3 +19,8 @@ AsyncStream,

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

@@ -29,3 +34,3 @@ export abstract class AsyncFastIteratorBase<T> implements AsyncFastIterator<T> {

const value = await this.fastNext(done);
if (done === value) return AsyncFastIterator.fixedDone;
if (done === value) return fixedDoneAsyncIteratorResult;
return { value, done: false };

@@ -47,3 +52,3 @@ }

const it1 = this[Symbol.asyncIterator]();
const it2 = AsyncStream.from(other)[Symbol.asyncIterator]();
const it2 = AsyncStreamConstructorsImpl.from(other)[Symbol.asyncIterator]();

@@ -440,3 +445,3 @@ const done = Symbol('Done');

take(amount: number): AsyncStream<T> {
if (amount <= 0) return AsyncStream.empty();
if (amount <= 0) return AsyncStreamConstructorsImpl.empty();

@@ -463,3 +468,3 @@ return new AsyncTakeStream<T>(this, amount);

concat(...others: ArrayNonEmpty<AsyncStreamSource<T>>): any {
if (others.every(AsyncStreamSource.isEmptyInstance)) return this;
if (others.every(isEmptyAsyncStreamSourceInstance)) return this;

@@ -528,5 +533,5 @@ return new AsyncConcatStream<T>(this, others);

intersperse(sep: AsyncStreamSource<T>): AsyncStream<T> {
if (AsyncStreamSource.isEmptyInstance(sep)) return this;
if (isEmptyAsyncStreamSourceInstance(sep)) return this;
const sepStream = AsyncStream.from(sep);
const sepStream = AsyncStreamConstructorsImpl.from(sep);

@@ -568,7 +573,11 @@ return new AsyncIntersperseStream<T>(this, sepStream);

mkGroup({
sep = AsyncStream.empty<T>() as AsyncStreamSource<T>,
start = AsyncStream.empty<T>() as AsyncStreamSource<T>,
end = AsyncStream.empty<T>() as AsyncStreamSource<T>,
sep = AsyncStreamConstructorsImpl.empty<T>() as AsyncStreamSource<T>,
start = AsyncStreamConstructorsImpl.empty<T>() as AsyncStreamSource<T>,
end = AsyncStreamConstructorsImpl.empty<T>() as AsyncStreamSource<T>,
} = {}): any {
return AsyncStream.from<T>(start, this.intersperse(sep), end);
return AsyncStreamConstructorsImpl.from<T>(
start,
this.intersperse(sep),
end
);
}

@@ -1126,3 +1135,3 @@

const currentIterator =
AsyncStream.from(nextSource)[Symbol.asyncIterator]();
AsyncStreamConstructorsImpl.from(nextSource)[Symbol.asyncIterator]();

@@ -1164,3 +1173,3 @@ this.currentIterator = currentIterator;

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

@@ -1172,3 +1181,4 @@ return AsyncOptLazy.toMaybePromise(otherwise!);

this.iterator = AsyncStream.from(nextSource)[Symbol.asyncIterator]();
this.iterator =
AsyncStreamConstructorsImpl.from(nextSource)[Symbol.asyncIterator]();
}

@@ -1175,0 +1185,0 @@

@@ -9,5 +9,4 @@ import { RimbuError, Token } from '@rimbu/base';

} from '@rimbu/common';
import { Stream } from '@rimbu/stream';
import type { AsyncStream } from '@rimbu/stream/async';
import { AsyncFastIterator, AsyncStreamSource } from '@rimbu/stream/async';
import type { AsyncFastIterator, AsyncStreamSource } from '@rimbu/stream/async';
import {

@@ -18,3 +17,7 @@ AsyncFastIteratorBase,

closeIters,
emptyAsyncFastIterator,
isAsyncFastIterator,
isEmptyAsyncStreamSourceInstance,
} from '@rimbu/stream/async-custom';
import { StreamConstructorsImpl } from '@rimbu/stream/custom';

@@ -58,3 +61,3 @@ class AsyncOfIterator<T> extends AsyncFastIteratorBase<T> {

if (isAsyncStream(source)) return source;
if (AsyncStreamSource.isEmptyInstance(source))
if (isEmptyAsyncStreamSourceInstance(source))
return AsyncStreamConstructorsImpl.empty();

@@ -70,3 +73,3 @@

[Symbol.asyncIterator](): AsyncFastIterator<T> {
return AsyncFastIterator.emptyAsyncFastIterator;
return emptyAsyncFastIterator;
}

@@ -174,3 +177,3 @@

concat(...others: ArrayNonEmpty<AsyncStreamSource<T>>): any {
if (others.every(AsyncStreamSource.isEmptyInstance)) return this;
if (others.every(isEmptyAsyncStreamSourceInstance)) return this;
const [source1, source2, ...sources] = others;

@@ -327,4 +330,4 @@

if (AsyncStreamSource.isEmptyInstance(source)) {
return AsyncFastIterator.emptyAsyncFastIterator;
if (isEmptyAsyncStreamSourceInstance(source)) {
return emptyAsyncFastIterator;
}

@@ -340,3 +343,3 @@

if (AsyncFastIterator.isAsyncFastIterator(iterator)) {
if (isAsyncFastIterator(iterator)) {
if (undefined === close) {

@@ -762,3 +765,3 @@ return iterator as AsyncFastIterator<T>;

return (zipFun: any): any => {
if (sources.some(AsyncStreamSource.isEmptyInstance)) {
if (sources.some(isEmptyAsyncStreamSourceInstance)) {
return AsyncStreamConstructorsImpl.empty();

@@ -777,3 +780,3 @@ }

return (fillValue: any, zipFun: any): any => {
if (sources.every(AsyncStreamSource.isEmptyInstance)) {
if (sources.every(isEmptyAsyncStreamSourceInstance)) {
return AsyncStreamConstructorsImpl.empty();

@@ -798,4 +801,4 @@ }

unzip(source, length) {
if (AsyncStreamSource.isEmptyInstance(source)) {
return Stream.of(AsyncStreamConstructorsImpl.empty())
if (isEmptyAsyncStreamSourceInstance(source)) {
return StreamConstructorsImpl.of(AsyncStreamConstructorsImpl.empty())
.repeat(length)

@@ -802,0 +805,0 @@ .toArray();

@@ -0,3 +1,5 @@

export * from './async-fast-iterator-base';
export * from './async-stream-source-base';
export * from './async-stream-custom';
export * from './constructors';
export * from './utils';

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

import { AsyncOptLazy, MaybePromise } from '@rimbu/common';
import type { AsyncOptLazy, MaybePromise } from '@rimbu/common';

@@ -8,23 +8,1 @@ export interface AsyncFastIterator<T> extends AsyncIterator<T> {

}
export namespace AsyncFastIterator {
export const fixedDone = Promise.resolve({
done: true,
value: undefined,
} as IteratorResult<any>);
export function isAsyncFastIterator<T>(
iterator: AsyncIterator<T>
): iterator is AsyncFastIterator<T> {
return `fastNext` in iterator;
}
export const emptyAsyncFastIterator: AsyncFastIterator<any> = {
fastNext<O>(otherwise?: AsyncOptLazy<O>): MaybePromise<O> {
return AsyncOptLazy.toMaybePromise(otherwise!);
},
next(): Promise<IteratorResult<any>> {
return fixedDone;
},
};
}
import type { MaybePromise } from '@rimbu/common';
import { StreamSource } from '@rimbu/stream';
import { AsyncStream, AsyncStreamable } from '@rimbu/stream/async';
import type { StreamSource } from '@rimbu/stream';
import type { AsyncStream, AsyncStreamable } from '@rimbu/stream/async';

@@ -20,9 +20,2 @@ export type AsyncStreamSource<T> =

| (() => MaybePromise<AsyncStreamSource.NonEmpty<T>>);
export function isEmptyInstance(source: AsyncStreamSource<any>): boolean {
return (
source === AsyncStream.empty() ||
StreamSource.isEmptyInstance(source as StreamSource<any>)
);
}
}

@@ -13,5 +13,5 @@ import { RimbuError, Token } from '@rimbu/base';

} from '@rimbu/common';
import type { Stream } from '@rimbu/stream';
import { FastIterator, StreamSource } from '@rimbu/stream';
import type { Stream, FastIterator, StreamSource } from '@rimbu/stream';
import {
emptyFastIterator,
FastIteratorBase,

@@ -21,2 +21,3 @@ FromIterable,

StreamBase,
isEmptyStreamSourceInstance,
} from '@rimbu/stream/custom';

@@ -26,3 +27,3 @@

[Symbol.iterator](): FastIterator<T> {
return FastIterator.emptyFastIterator;
return emptyFastIterator;
}

@@ -130,3 +131,3 @@

concat<T2>(...others: ArrayNonEmpty<StreamSource<T2>>): any {
if (others.every(StreamSource.isEmptyInstance)) return this;
if (others.every(isEmptyStreamSourceInstance)) return this;
const [source1, source2, ...sources] = others;

@@ -199,3 +200,3 @@

} = <T>(source: StreamSource<T>): any => {
if (undefined === source || StreamSource.isEmptyInstance(source))
if (undefined === source || isEmptyStreamSourceInstance(source))
return StreamConstructorsImpl.empty();

@@ -1390,3 +1391,3 @@ if (isStream(source)) return source;

return (zipFun): any => {
if (sources.some(StreamSource.isEmptyInstance)) {
if (sources.some(isEmptyStreamSourceInstance)) {
return StreamConstructorsImpl.empty();

@@ -1403,3 +1404,3 @@ }

return (fillValue, zipFun: any): any => {
if (sources.every(StreamSource.isEmptyInstance)) {
if (sources.every(isEmptyStreamSourceInstance)) {
return StreamConstructorsImpl.empty();

@@ -1424,3 +1425,3 @@ }

unzip(source, length) {
if (StreamSource.isEmptyInstance(source)) {
if (isEmptyStreamSourceInstance(source)) {
return StreamConstructorsImpl.of(StreamConstructorsImpl.empty())

@@ -1427,0 +1428,0 @@ .repeat(length)

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

export * from './fast-iterator-custom';
export * from './stream-source-base';
export * from './stream-custom';
export * from './constructors';

@@ -11,3 +11,9 @@ import {

} from '@rimbu/common';
import { FastIterator, Stream, StreamSource } from '@rimbu/stream';
import type { FastIterator, Stream, StreamSource } from '@rimbu/stream';
import {
fixedDoneIteratorResult,
isEmptyStreamSourceInstance,
isFastIterator,
StreamConstructorsImpl,
} from '@rimbu/stream/custom';

@@ -24,3 +30,3 @@ /**

const value = this.fastNext(done);
if (done === value) return FastIterator.fixedDone;
if (done === value) return fixedDoneIteratorResult;
return { value, done: false };

@@ -39,3 +45,3 @@ }

const it1 = this[Symbol.iterator]();
const it2 = Stream.from(other)[Symbol.iterator]();
const it2 = StreamConstructorsImpl.from(other)[Symbol.iterator]();

@@ -122,6 +128,5 @@ const done = Symbol('Done');

return this.flatMap((value, index, halt) =>
Stream.from(flatMapFun(value, index, halt)).map((result) => [
value,
result,
])
StreamConstructorsImpl.from(flatMapFun(value, index, halt)).map(
(result) => [value, result]
)
);

@@ -342,3 +347,3 @@ }

take(amount: number): Stream<T> {
if (amount <= 0) return Stream.empty();
if (amount <= 0) return StreamConstructorsImpl.empty();

@@ -361,3 +366,3 @@ return new TakeStream<T>(this, amount);

concat(...others: ArrayNonEmpty<StreamSource<T>>): Stream.NonEmpty<T> {
if (others.every(StreamSource.isEmptyInstance)) {
if (others.every(isEmptyStreamSourceInstance)) {
return this.assumeNonEmpty();

@@ -408,5 +413,5 @@ }

intersperse(sep: StreamSource<T>): Stream<T> {
if (StreamSource.isEmptyInstance(sep)) return this;
if (isEmptyStreamSourceInstance(sep)) return this;
const sepStream = Stream.from(sep);
const sepStream = StreamConstructorsImpl.from(sep);

@@ -442,7 +447,7 @@ return new IntersperseStream<T>(this, sepStream);

mkGroup({
sep = Stream.empty<T>() as StreamSource<T>,
start = Stream.empty<T>() as StreamSource<T>,
end = Stream.empty<T>() as StreamSource<T>,
sep = StreamConstructorsImpl.empty<T>() as StreamSource<T>,
start = StreamConstructorsImpl.empty<T>() as StreamSource<T>,
end = StreamConstructorsImpl.empty<T>() as StreamSource<T>,
} = {}): any {
return Stream.from<T>(start, this.intersperse(sep), end);
return StreamConstructorsImpl.from<T>(start, this.intersperse(sep), end);
}

@@ -894,3 +899,4 @@

this.currentIterator = Stream.from(nextSource)[Symbol.iterator]();
this.currentIterator =
StreamConstructorsImpl.from(nextSource)[Symbol.iterator]();
}

@@ -943,3 +949,3 @@

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

@@ -949,3 +955,4 @@ nextSource = this.otherSources[this.sourceIndex++];

this.iterator = Stream.from(nextSource)[Symbol.iterator]();
this.iterator =
StreamConstructorsImpl.from(nextSource)[Symbol.iterator]();
}

@@ -984,4 +991,4 @@

if (!StreamSource.isEmptyInstance(source)) {
Stream.from(source).forEach(f, state);
if (!isEmptyStreamSourceInstance(source)) {
StreamConstructorsImpl.from(source).forEach(f, state);
}

@@ -998,5 +1005,5 @@ }

if (!StreamSource.isEmptyInstance(source)) {
if (!isEmptyStreamSourceInstance(source)) {
const done = Symbol('Done');
const value = Stream.from(source).last(done);
const value = StreamConstructorsImpl.from(source).last(done);
if (done !== value) return value;

@@ -1018,4 +1025,4 @@ }

const source = sources[sourceIndex];
if (!StreamSource.isEmptyInstance(source)) {
result += Stream.from(source).count();
if (!isEmptyStreamSourceInstance(source)) {
result += StreamConstructorsImpl.from(source).count();
}

@@ -1044,4 +1051,4 @@ }

if (!StreamSource.isEmptyInstance(source)) {
result = result.concat(Stream.from(source).toArray());
if (!isEmptyStreamSourceInstance(source)) {
result = result.concat(StreamConstructorsImpl.from(source).toArray());
}

@@ -1781,3 +1788,3 @@ }

if (FastIterator.isFastIterator(iterator)) return iterator;
if (isFastIterator(iterator)) return iterator;

@@ -1784,0 +1791,0 @@ return new SlowIteratorAdapter<T>(iterator);

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

import { OptLazy } from '@rimbu/common';
import type { OptLazy } from '@rimbu/common';

@@ -19,25 +19,1 @@ /**

}
const _fixedDone: IteratorResult<any> = {
done: true,
value: undefined,
};
export namespace FastIterator {
export const fixedDone: IteratorResult<any> = _fixedDone;
export const emptyFastIterator: FastIterator<any> = {
fastNext<O>(otherwise?: OptLazy<O>): O {
return OptLazy(otherwise) as O;
},
next(): IteratorResult<any> {
return _fixedDone;
},
};
export function isFastIterator<T>(
iterator: Iterator<T>
): iterator is FastIterator<T> {
return `fastNext` in iterator;
}
}

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

import { Stream, Streamable } from '@rimbu/stream';
import type { Stream, Streamable } from '@rimbu/stream';

@@ -22,21 +22,2 @@ /**

| readonly [T, ...T[]];
/**
* Returns true if the given `source` StreamSource is known to be empty.
* @param source - a StreamSource
* @note
* If this function returns false, it does not guarantee that the Stream is not empty. It only
* means that it is not known if it is empty.
*/
export function isEmptyInstance(source: StreamSource<unknown>): boolean {
if (source === '') return true;
if (typeof source === 'object') {
if (source === Stream.empty()) return true;
if (`length` in source && (source as any).length === 0) return true;
if (`size` in source && (source as any).size === 0) return true;
if (`isEmpty` in source && (source as any).isEmpty === true) return true;
}
return false;
}
}

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

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

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc