@rimbu/stream
Advanced tools
Comparing version 0.5.7 to 0.5.8
@@ -8,2 +8,3 @@ "use strict"; | ||
var internal_1 = require("./internal"); | ||
var stream_custom_1 = require("./stream-custom"); | ||
var EmptyStream = /** @class */ (function (_super) { | ||
@@ -180,6 +181,6 @@ tslib_1.__extends(EmptyStream, _super); | ||
return EmptyStream; | ||
}(internal_1.StreamCustom.StreamBase)); | ||
}(stream_custom_1.StreamBase)); | ||
var _empty = new EmptyStream(); | ||
function isStream(obj) { | ||
return obj instanceof internal_1.StreamCustom.StreamBase; | ||
return obj instanceof stream_custom_1.StreamBase; | ||
} | ||
@@ -198,3 +199,3 @@ var fromStreamSource = function (source) { | ||
} | ||
return new internal_1.StreamCustom.FromIterable(source); | ||
return new stream_custom_1.FromIterable(source); | ||
}; | ||
@@ -489,3 +490,3 @@ /** | ||
function random() { | ||
return new internal_1.StreamCustom.FromStream(function () { return new RandomIterator(); }); | ||
return new stream_custom_1.FromStream(function () { return new RandomIterator(); }); | ||
} | ||
@@ -503,3 +504,3 @@ exports.random = random; | ||
common_1.Err.msg('min should be smaller than max'); | ||
return new internal_1.StreamCustom.FromStream(function () { return new RandomIntIterator(min, max); }); | ||
return new stream_custom_1.FromStream(function () { return new RandomIntIterator(min, max); }); | ||
} | ||
@@ -515,3 +516,3 @@ exports.randomInt = randomInt; | ||
function unfold(init, next) { | ||
return new internal_1.StreamCustom.FromStream(function () { return new UnfoldIterator(init, next); }); | ||
return new stream_custom_1.FromStream(function () { return new UnfoldIterator(init, next); }); | ||
} | ||
@@ -535,3 +536,3 @@ exports.unfold = unfold; | ||
return ArrayIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var ArrayReverseIterator = /** @class */ (function (_super) { | ||
@@ -552,3 +553,3 @@ tslib_1.__extends(ArrayReverseIterator, _super); | ||
return ArrayReverseIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var ArrayStream = /** @class */ (function (_super) { | ||
@@ -750,3 +751,3 @@ tslib_1.__extends(ArrayStream, _super); | ||
return ArrayStream; | ||
}(internal_1.StreamCustom.StreamBase)); | ||
}(stream_custom_1.StreamBase)); | ||
var MapApplyIterator = /** @class */ (function (_super) { | ||
@@ -770,3 +771,3 @@ tslib_1.__extends(MapApplyIterator, _super); | ||
return MapApplyIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var MapApplyStream = /** @class */ (function (_super) { | ||
@@ -785,3 +786,3 @@ tslib_1.__extends(MapApplyStream, _super); | ||
return MapApplyStream; | ||
}(internal_1.StreamCustom.StreamBase)); | ||
}(stream_custom_1.StreamBase)); | ||
var FilterApplyIterator = /** @class */ (function (_super) { | ||
@@ -818,3 +819,3 @@ tslib_1.__extends(FilterApplyIterator, _super); | ||
return FilterApplyIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var FilterApplyStream = /** @class */ (function (_super) { | ||
@@ -835,3 +836,3 @@ tslib_1.__extends(FilterApplyStream, _super); | ||
return FilterApplyStream; | ||
}(internal_1.StreamCustom.StreamBase)); | ||
}(stream_custom_1.StreamBase)); | ||
var RangeUpIterator = /** @class */ (function (_super) { | ||
@@ -859,3 +860,3 @@ tslib_1.__extends(RangeUpIterator, _super); | ||
return RangeUpIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var RangeDownIterator = /** @class */ (function (_super) { | ||
@@ -883,3 +884,3 @@ tslib_1.__extends(RangeDownIterator, _super); | ||
return RangeDownIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var RangeStream = /** @class */ (function (_super) { | ||
@@ -902,3 +903,3 @@ tslib_1.__extends(RangeStream, _super); | ||
return RangeStream; | ||
}(internal_1.StreamCustom.StreamBase)); | ||
}(stream_custom_1.StreamBase)); | ||
var RandomIterator = /** @class */ (function (_super) { | ||
@@ -913,3 +914,3 @@ tslib_1.__extends(RandomIterator, _super); | ||
return RandomIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var RandomIntIterator = /** @class */ (function (_super) { | ||
@@ -928,3 +929,3 @@ tslib_1.__extends(RandomIntIterator, _super); | ||
return RandomIntIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
var UnfoldIterator = /** @class */ (function (_super) { | ||
@@ -954,3 +955,3 @@ tslib_1.__extends(UnfoldIterator, _super); | ||
return UnfoldIterator; | ||
}(internal_1.FastIterator.Base)); | ||
}(stream_custom_1.FastIteratorBase)); | ||
//# sourceMappingURL=constructors.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FastIterator = void 0; | ||
var common_1 = require("@rimbu/common"); | ||
var FastIterator; | ||
(function (FastIterator) { | ||
FastIterator.fixedDone = { | ||
done: true, | ||
value: undefined, | ||
}; | ||
FastIterator.emptyFastIterator = { | ||
fastNext: function (otherwise) { | ||
return common_1.OptLazy(otherwise); | ||
}, | ||
next: function () { | ||
return FastIterator.fixedDone; | ||
}, | ||
}; | ||
/** | ||
* A base class for `FastIterator` instances, that takes implements the default `next` | ||
* function based on the abstract `fastNext` function. | ||
*/ | ||
var Base = /** @class */ (function () { | ||
function Base() { | ||
} | ||
Base.prototype.next = function () { | ||
var done = Symbol('Done'); | ||
var value = this.fastNext(done); | ||
if (done === value) | ||
return FastIterator.fixedDone; | ||
return { value: value, done: false }; | ||
}; | ||
return Base; | ||
}()); | ||
FastIterator.Base = Base; | ||
})(FastIterator = exports.FastIterator || (exports.FastIterator = {})); | ||
//# sourceMappingURL=fast-iterable.js.map |
@@ -5,3 +5,4 @@ "use strict"; | ||
var tslib_1 = require("tslib"); | ||
exports.StreamCustom = tslib_1.__importStar(require("./implementation")); | ||
exports.StreamCustom = tslib_1.__importStar(require("./stream-custom")); | ||
tslib_1.__exportStar(require("./fast-iterator"), exports); | ||
tslib_1.__exportStar(require("./fast-iterable"), exports); | ||
@@ -8,0 +9,0 @@ tslib_1.__exportStar(require("./interface"), exports); |
import { RimbuError, Token } from '@rimbu/base'; | ||
import { Err, IndexRange, OptLazy, Range, Reducer, TraverseState, } from '@rimbu/common'; | ||
import { FastIterator, Stream, StreamCustom as SC, StreamSource, } from './internal'; | ||
class EmptyStream extends SC.StreamBase { | ||
import { FastIterator, Stream, StreamSource } from './internal'; | ||
import { FastIteratorBase, FromIterable, FromStream, StreamBase } from './stream-custom'; | ||
class EmptyStream extends StreamBase { | ||
[Symbol.iterator]() { | ||
@@ -163,3 +164,3 @@ return FastIterator.emptyFastIterator; | ||
function isStream(obj) { | ||
return obj instanceof SC.StreamBase; | ||
return obj instanceof StreamBase; | ||
} | ||
@@ -178,3 +179,3 @@ const fromStreamSource = (source) => { | ||
} | ||
return new SC.FromIterable(source); | ||
return new FromIterable(source); | ||
}; | ||
@@ -426,3 +427,3 @@ /** | ||
export function random() { | ||
return new SC.FromStream(() => new RandomIterator()); | ||
return new FromStream(() => new RandomIterator()); | ||
} | ||
@@ -439,3 +440,3 @@ /** | ||
Err.msg('min should be smaller than max'); | ||
return new SC.FromStream(() => new RandomIntIterator(min, max)); | ||
return new FromStream(() => new RandomIntIterator(min, max)); | ||
} | ||
@@ -450,5 +451,5 @@ /** | ||
export function unfold(init, next) { | ||
return new SC.FromStream(() => new UnfoldIterator(init, next)); | ||
return new FromStream(() => new UnfoldIterator(init, next)); | ||
} | ||
class ArrayIterator extends FastIterator.Base { | ||
class ArrayIterator extends FastIteratorBase { | ||
constructor(array, startIndex, endIndex) { | ||
@@ -467,3 +468,3 @@ super(); | ||
} | ||
class ArrayReverseIterator extends FastIterator.Base { | ||
class ArrayReverseIterator extends FastIteratorBase { | ||
constructor(array, startIndex, endIndex) { | ||
@@ -481,3 +482,3 @@ super(); | ||
} | ||
class ArrayStream extends SC.StreamBase { | ||
class ArrayStream extends StreamBase { | ||
constructor(array, startIndex = 0, endIndex = array.length - 1, reversed = false) { | ||
@@ -667,3 +668,3 @@ super(); | ||
} | ||
class MapApplyIterator extends FastIterator.Base { | ||
class MapApplyIterator extends FastIteratorBase { | ||
constructor(source, f, args) { | ||
@@ -684,3 +685,3 @@ super(); | ||
} | ||
class MapApplyStream extends SC.StreamBase { | ||
class MapApplyStream extends StreamBase { | ||
constructor(source, f, args) { | ||
@@ -696,3 +697,3 @@ super(); | ||
} | ||
class FilterApplyIterator extends FastIterator.Base { | ||
class FilterApplyIterator extends FastIteratorBase { | ||
constructor(source, pred, args, invert) { | ||
@@ -726,3 +727,3 @@ super(); | ||
} | ||
class FilterApplyStream extends SC.StreamBase { | ||
class FilterApplyStream extends StreamBase { | ||
constructor(source, pred, args, invert = false) { | ||
@@ -739,3 +740,3 @@ super(); | ||
} | ||
class RangeUpIterator extends FastIterator.Base { | ||
class RangeUpIterator extends FastIteratorBase { | ||
constructor(start = 0, end, delta) { | ||
@@ -759,3 +760,3 @@ super(); | ||
} | ||
class RangeDownIterator extends FastIterator.Base { | ||
class RangeDownIterator extends FastIteratorBase { | ||
constructor(start = 0, end, delta) { | ||
@@ -779,3 +780,3 @@ super(); | ||
} | ||
class RangeStream extends SC.StreamBase { | ||
class RangeStream extends StreamBase { | ||
constructor(start, end, delta = 1) { | ||
@@ -794,3 +795,3 @@ super(); | ||
} | ||
class RandomIterator extends FastIterator.Base { | ||
class RandomIterator extends FastIteratorBase { | ||
fastNext() { | ||
@@ -800,3 +801,3 @@ return Math.random(); | ||
} | ||
class RandomIntIterator extends FastIterator.Base { | ||
class RandomIntIterator extends FastIteratorBase { | ||
constructor(min, max) { | ||
@@ -812,3 +813,3 @@ super(); | ||
} | ||
class UnfoldIterator extends FastIterator.Base { | ||
class UnfoldIterator extends FastIteratorBase { | ||
constructor(init, getNext) { | ||
@@ -815,0 +816,0 @@ super(); |
@@ -1,31 +0,2 @@ | ||
import { OptLazy } from '@rimbu/common'; | ||
export var FastIterator; | ||
(function (FastIterator) { | ||
FastIterator.fixedDone = { | ||
done: true, | ||
value: undefined, | ||
}; | ||
FastIterator.emptyFastIterator = { | ||
fastNext(otherwise) { | ||
return OptLazy(otherwise); | ||
}, | ||
next() { | ||
return FastIterator.fixedDone; | ||
}, | ||
}; | ||
/** | ||
* A base class for `FastIterator` instances, that takes implements the default `next` | ||
* function based on the abstract `fastNext` function. | ||
*/ | ||
class Base { | ||
next() { | ||
const done = Symbol('Done'); | ||
const value = this.fastNext(done); | ||
if (done === value) | ||
return FastIterator.fixedDone; | ||
return { value, done: false }; | ||
} | ||
} | ||
FastIterator.Base = Base; | ||
})(FastIterator || (FastIterator = {})); | ||
export {}; | ||
//# sourceMappingURL=fast-iterable.js.map |
@@ -1,2 +0,3 @@ | ||
export * as StreamCustom from './implementation'; | ||
export * as StreamCustom from './stream-custom'; | ||
export * from './fast-iterator'; | ||
export * from './fast-iterable'; | ||
@@ -3,0 +4,0 @@ export * from './interface'; |
@@ -1,31 +0,3 @@ | ||
import { OptLazy } from '@rimbu/common'; | ||
import { FastIterator } from './internal'; | ||
/** | ||
* An iterator that extends the default `Iterator` interface with methods that give more performance. | ||
*/ | ||
export interface FastIterator<T> extends Iterator<T> { | ||
/** | ||
* Returns the next iterator value, or the given `otherwise` `OptLazy` value instead. | ||
* @param otherwise - (default: undefined) the value to return if the iterator has no more values | ||
*/ | ||
fastNext(): T | undefined; | ||
fastNext<O>(otherwise: OptLazy<O>): T | O; | ||
/** | ||
* Returns the next `IteratorResult`. | ||
* @see {Iterator} | ||
*/ | ||
next(): IteratorResult<T>; | ||
} | ||
export declare namespace FastIterator { | ||
const fixedDone: IteratorResult<any>; | ||
const emptyFastIterator: FastIterator<any>; | ||
/** | ||
* A base class for `FastIterator` instances, that takes implements the default `next` | ||
* function based on the abstract `fastNext` function. | ||
*/ | ||
abstract class Base<T> implements FastIterator<T> { | ||
abstract fastNext<O>(otherwise?: OptLazy<O>): T | O; | ||
next(): IteratorResult<T>; | ||
} | ||
} | ||
/** | ||
* An interface that extends the standard `Iterable` interface to return | ||
@@ -32,0 +4,0 @@ * a `FastIterator` instead of a normal `Iterator`. |
@@ -1,2 +0,3 @@ | ||
export * as StreamCustom from './implementation'; | ||
export * as StreamCustom from './stream-custom'; | ||
export * from './fast-iterator'; | ||
export * from './fast-iterable'; | ||
@@ -3,0 +4,0 @@ export * from './interface'; |
{ | ||
"name": "@rimbu/stream", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript", | ||
@@ -71,3 +71,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "a7e255d1e63ad6baaa02f3e9c6540b8a907752e0" | ||
"gitHead": "98155e4b35ca452566dde32247d898897258aff8" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48
6239
376750
1