@rimbu/stream
Advanced tools
Comparing version 0.10.4 to 0.10.5
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ZipAllWithItererator = exports.ZipWithIterator = exports.UnfoldIterator = exports.RandomIntIterator = exports.RandomIterator = exports.RangeDownIterator = exports.RangeUpIterator = exports.FilterApplyIterator = exports.MapApplyIterator = exports.AlwaysIterator = exports.ArrayReverseIterator = exports.ArrayIterator = exports.ReduceAllIterator = exports.ReduceIterator = exports.SplitOnIterator = exports.SplitWhereIterator = exports.IntersperseIterator = exports.RepeatIterator = exports.DropIterator = exports.TakeIterator = exports.DropWhileIterator = exports.TakeWhileIterator = exports.IndicesOfIterator = exports.IndicesWhereIterator = exports.CollectIterator = exports.FilterPureIterator = exports.FilterIterator = exports.ConcatIterator = exports.FlatMapIterator = exports.FastIteratorBase = exports.isFastIterator = exports.emptyFastIterator = exports.fixedDoneIteratorResult = void 0; | ||
exports.MapPureIterator = exports.MapIterator = exports.IndexedIterator = exports.AppendIterator = exports.PrependIterator = exports.ZipAllWithItererator = exports.ZipWithIterator = exports.UnfoldIterator = exports.RandomIntIterator = exports.RandomIterator = exports.RangeDownIterator = exports.RangeUpIterator = exports.FilterApplyIterator = exports.MapApplyIterator = exports.AlwaysIterator = exports.ArrayReverseIterator = exports.ArrayIterator = exports.ReduceAllIterator = exports.ReduceIterator = exports.SplitOnIterator = exports.SplitWhereIterator = exports.IntersperseIterator = exports.RepeatIterator = exports.DropIterator = exports.TakeIterator = exports.DropWhileIterator = exports.TakeWhileIterator = exports.IndicesOfIterator = exports.IndicesWhereIterator = exports.CollectIterator = exports.FilterPureIterator = exports.FilterIterator = exports.ConcatIterator = exports.FlatMapIterator = exports.FastIteratorBase = exports.isFastIterator = exports.emptyFastIterator = exports.fixedDoneIteratorResult = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -818,2 +818,103 @@ var base_1 = require("@rimbu/base"); | ||
exports.ZipAllWithItererator = ZipAllWithItererator; | ||
var PrependIterator = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(PrependIterator, _super); | ||
function PrependIterator(source, item) { | ||
var _this = _super.call(this) || this; | ||
_this.source = source; | ||
_this.item = item; | ||
_this.prependDone = false; | ||
return _this; | ||
} | ||
PrependIterator.prototype.fastNext = function (otherwise) { | ||
if (this.prependDone) | ||
return this.source.fastNext(otherwise); | ||
this.prependDone = true; | ||
return (0, common_1.OptLazy)(this.item); | ||
}; | ||
return PrependIterator; | ||
}(FastIteratorBase)); | ||
exports.PrependIterator = PrependIterator; | ||
var AppendIterator = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(AppendIterator, _super); | ||
function AppendIterator(source, item) { | ||
var _this = _super.call(this) || this; | ||
_this.source = source; | ||
_this.item = item; | ||
_this.appendDone = false; | ||
return _this; | ||
} | ||
AppendIterator.prototype.fastNext = function (otherwise) { | ||
if (this.appendDone) | ||
return (0, common_1.OptLazy)(otherwise); | ||
var done = Symbol('Done'); | ||
var value = this.source.fastNext(done); | ||
if (done !== value) | ||
return value; | ||
this.appendDone = true; | ||
return (0, common_1.OptLazy)(this.item); | ||
}; | ||
return AppendIterator; | ||
}(FastIteratorBase)); | ||
exports.AppendIterator = AppendIterator; | ||
var IndexedIterator = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(IndexedIterator, _super); | ||
function IndexedIterator(source, startIndex) { | ||
if (startIndex === void 0) { startIndex = 0; } | ||
var _this = _super.call(this) || this; | ||
_this.source = source; | ||
_this.startIndex = startIndex; | ||
_this.index = startIndex; | ||
return _this; | ||
} | ||
IndexedIterator.prototype.fastNext = function (otherwise) { | ||
var done = Symbol('Done'); | ||
var value = this.source.fastNext(done); | ||
if (done === value) | ||
return (0, common_1.OptLazy)(otherwise); | ||
return [this.index++, value]; | ||
}; | ||
return IndexedIterator; | ||
}(FastIteratorBase)); | ||
exports.IndexedIterator = IndexedIterator; | ||
var MapIterator = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(MapIterator, _super); | ||
function MapIterator(source, mapFun) { | ||
var _this = _super.call(this) || this; | ||
_this.source = source; | ||
_this.mapFun = mapFun; | ||
_this.state = (0, common_1.TraverseState)(); | ||
return _this; | ||
} | ||
MapIterator.prototype.fastNext = function (otherwise) { | ||
var state = this.state; | ||
if (state.halted) | ||
return (0, common_1.OptLazy)(otherwise); | ||
var done = Symbol('Done'); | ||
var next = this.source.fastNext(done); | ||
if (done === next) | ||
return (0, common_1.OptLazy)(otherwise); | ||
return this.mapFun(next, state.nextIndex()); | ||
}; | ||
return MapIterator; | ||
}(FastIteratorBase)); | ||
exports.MapIterator = MapIterator; | ||
var MapPureIterator = /** @class */ (function (_super) { | ||
(0, tslib_1.__extends)(MapPureIterator, _super); | ||
function MapPureIterator(source, mapFun, args) { | ||
var _this = _super.call(this) || this; | ||
_this.source = source; | ||
_this.mapFun = mapFun; | ||
_this.args = args; | ||
return _this; | ||
} | ||
MapPureIterator.prototype.fastNext = function (otherwise) { | ||
var done = Symbol('Done'); | ||
var next = this.source.fastNext(done); | ||
if (done === next) | ||
return (0, common_1.OptLazy)(otherwise); | ||
return this.mapFun.apply(this, (0, tslib_1.__spreadArray)([next], (0, tslib_1.__read)(this.args), false)); | ||
}; | ||
return MapPureIterator; | ||
}(FastIteratorBase)); | ||
exports.MapPureIterator = MapPureIterator; | ||
//# sourceMappingURL=fast-iterator-custom.js.map |
@@ -687,2 +687,82 @@ import { Token } from '@rimbu/base'; | ||
} | ||
export class PrependIterator extends FastIteratorBase { | ||
constructor(source, item) { | ||
super(); | ||
this.source = source; | ||
this.item = item; | ||
this.prependDone = false; | ||
} | ||
fastNext(otherwise) { | ||
if (this.prependDone) | ||
return this.source.fastNext(otherwise); | ||
this.prependDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
export class AppendIterator extends FastIteratorBase { | ||
constructor(source, item) { | ||
super(); | ||
this.source = source; | ||
this.item = item; | ||
this.appendDone = false; | ||
} | ||
fastNext(otherwise) { | ||
if (this.appendDone) | ||
return OptLazy(otherwise); | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done !== value) | ||
return value; | ||
this.appendDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
export class IndexedIterator extends FastIteratorBase { | ||
constructor(source, startIndex = 0) { | ||
super(); | ||
this.source = source; | ||
this.startIndex = startIndex; | ||
this.index = startIndex; | ||
} | ||
fastNext(otherwise) { | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done === value) | ||
return OptLazy(otherwise); | ||
return [this.index++, value]; | ||
} | ||
} | ||
export class MapIterator extends FastIteratorBase { | ||
constructor(source, mapFun) { | ||
super(); | ||
this.source = source; | ||
this.mapFun = mapFun; | ||
this.state = TraverseState(); | ||
} | ||
fastNext(otherwise) { | ||
const state = this.state; | ||
if (state.halted) | ||
return OptLazy(otherwise); | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) | ||
return OptLazy(otherwise); | ||
return this.mapFun(next, state.nextIndex()); | ||
} | ||
} | ||
export class MapPureIterator extends FastIteratorBase { | ||
constructor(source, mapFun, args) { | ||
super(); | ||
this.source = source; | ||
this.mapFun = mapFun; | ||
this.args = args; | ||
} | ||
fastNext(otherwise) { | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) | ||
return OptLazy(otherwise); | ||
return this.mapFun(next, ...this.args); | ||
} | ||
} | ||
//# sourceMappingURL=fast-iterator-custom.js.map |
import { Comp, Eq, ErrBase, IndexRange, OptLazy, Range, Reducer, TraverseState, } from '@rimbu/common'; | ||
import { isFastIterator, FastIteratorBase, 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, } from '@rimbu/stream/custom'; | ||
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, } from '@rimbu/stream/custom'; | ||
import { RimbuError } from '@rimbu/base'; | ||
@@ -390,16 +390,2 @@ export class StreamBase { | ||
Symbol.iterator; | ||
class PrependIterator extends FastIteratorBase { | ||
constructor(source, item) { | ||
super(); | ||
this.source = source; | ||
this.item = item; | ||
this.prependDone = false; | ||
} | ||
fastNext(otherwise) { | ||
if (this.prependDone) | ||
return this.source.fastNext(otherwise); | ||
this.prependDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
class PrependStream extends StreamBase { | ||
@@ -432,20 +418,2 @@ constructor(source, item) { | ||
} | ||
class AppendIterator extends FastIteratorBase { | ||
constructor(source, item) { | ||
super(); | ||
this.source = source; | ||
this.item = item; | ||
this.appendDone = false; | ||
} | ||
fastNext(otherwise) { | ||
if (this.appendDone) | ||
return OptLazy(otherwise); | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done !== value) | ||
return value; | ||
this.appendDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
class AppendStream extends StreamBase { | ||
@@ -478,17 +446,2 @@ constructor(source, item) { | ||
} | ||
class IndexedIterator extends FastIteratorBase { | ||
constructor(source, startIndex = 0) { | ||
super(); | ||
this.source = source; | ||
this.startIndex = startIndex; | ||
this.index = startIndex; | ||
} | ||
fastNext(otherwise) { | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done === value) | ||
return OptLazy(otherwise); | ||
return [this.index++, value]; | ||
} | ||
} | ||
class IndexedStream extends StreamBase { | ||
@@ -507,20 +460,2 @@ constructor(source, startIndex) { | ||
} | ||
class MapIterator extends FastIteratorBase { | ||
constructor(source, mapFun) { | ||
super(); | ||
this.source = source; | ||
this.mapFun = mapFun; | ||
this.state = TraverseState(); | ||
} | ||
fastNext(otherwise) { | ||
const state = this.state; | ||
if (state.halted) | ||
return OptLazy(otherwise); | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) | ||
return OptLazy(otherwise); | ||
return this.mapFun(next, state.nextIndex()); | ||
} | ||
} | ||
class MapStream extends StreamBase { | ||
@@ -563,17 +498,2 @@ constructor(source, mapFun) { | ||
} | ||
class MapPureIterator extends FastIteratorBase { | ||
constructor(source, mapFun, args) { | ||
super(); | ||
this.source = source; | ||
this.mapFun = mapFun; | ||
this.args = args; | ||
} | ||
fastNext(otherwise) { | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) | ||
return OptLazy(otherwise); | ||
return this.mapFun(next, ...this.args); | ||
} | ||
} | ||
class MapPureStream extends StreamBase { | ||
@@ -580,0 +500,0 @@ constructor(source, mapFun, args) { |
@@ -250,1 +250,36 @@ import { Token } from '@rimbu/base'; | ||
} | ||
export declare class PrependIterator<T> extends FastIteratorBase<T> { | ||
readonly source: FastIterator<T>; | ||
readonly item: OptLazy<T>; | ||
constructor(source: FastIterator<T>, item: OptLazy<T>); | ||
prependDone: boolean; | ||
fastNext<O>(otherwise?: OptLazy<O>): T | O; | ||
} | ||
export declare class AppendIterator<T> extends FastIteratorBase<T> { | ||
readonly source: FastIterator<T>; | ||
readonly item: OptLazy<T>; | ||
constructor(source: FastIterator<T>, item: OptLazy<T>); | ||
appendDone: boolean; | ||
fastNext<O>(otherwise?: OptLazy<O>): T | O; | ||
} | ||
export declare class IndexedIterator<T> extends FastIteratorBase<[number, T]> { | ||
readonly source: FastIterator<T>; | ||
readonly startIndex: number; | ||
index: number; | ||
constructor(source: FastIterator<T>, startIndex?: number); | ||
fastNext<O>(otherwise?: OptLazy<O>): [number, T] | O; | ||
} | ||
export declare class MapIterator<T, T2> extends FastIteratorBase<T2> { | ||
readonly source: FastIterator<T>; | ||
readonly mapFun: (value: T, index: number) => T2; | ||
constructor(source: FastIterator<T>, mapFun: (value: T, index: number) => T2); | ||
readonly state: TraverseState; | ||
fastNext<O>(otherwise?: OptLazy<O>): T2 | O; | ||
} | ||
export declare class MapPureIterator<T, A extends readonly unknown[], T2> extends FastIteratorBase<T2> { | ||
readonly source: FastIterator<T>; | ||
readonly mapFun: (value: T, ...args: A) => T2; | ||
readonly args: A; | ||
constructor(source: FastIterator<T>, mapFun: (value: T, ...args: A) => T2, args: A); | ||
fastNext<O>(otherwise?: OptLazy<O>): T2 | O; | ||
} |
{ | ||
"name": "@rimbu/stream", | ||
"version": "0.10.4", | ||
"version": "0.10.5", | ||
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript", | ||
@@ -80,3 +80,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "0d6347c834acd4caa7b1789b6a8388cd09039c61" | ||
"gitHead": "c9c3842b12ed66ba247e3d5462c6b92b41e0007a" | ||
} |
export * from './constructors'; | ||
export * from './utils'; | ||
export * from './async-fast-iterator-base'; | ||
export * from './async-stream-custom'; |
@@ -911,1 +911,101 @@ import { Token } from '@rimbu/base'; | ||
} | ||
export class PrependIterator<T> extends FastIteratorBase<T> { | ||
constructor(readonly source: FastIterator<T>, readonly item: OptLazy<T>) { | ||
super(); | ||
} | ||
prependDone = false; | ||
fastNext<O>(otherwise?: OptLazy<O>): T | O { | ||
if (this.prependDone) return this.source.fastNext(otherwise!); | ||
this.prependDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
export class AppendIterator<T> extends FastIteratorBase<T> { | ||
constructor(readonly source: FastIterator<T>, readonly item: OptLazy<T>) { | ||
super(); | ||
} | ||
appendDone = false; | ||
fastNext<O>(otherwise?: OptLazy<O>): T | O { | ||
if (this.appendDone) return OptLazy(otherwise) as O; | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done !== value) return value; | ||
this.appendDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
export class IndexedIterator<T> extends FastIteratorBase<[number, T]> { | ||
index: number; | ||
constructor(readonly source: FastIterator<T>, readonly startIndex = 0) { | ||
super(); | ||
this.index = startIndex; | ||
} | ||
fastNext<O>(otherwise?: OptLazy<O>): [number, T] | O { | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done === value) return OptLazy(otherwise) as O; | ||
return [this.index++, value]; | ||
} | ||
} | ||
export class MapIterator<T, T2> extends FastIteratorBase<T2> { | ||
constructor( | ||
readonly source: FastIterator<T>, | ||
readonly mapFun: (value: T, index: number) => T2 | ||
) { | ||
super(); | ||
} | ||
readonly state = TraverseState(); | ||
fastNext<O>(otherwise?: OptLazy<O>): T2 | O { | ||
const state = this.state; | ||
if (state.halted) return OptLazy(otherwise) as O; | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) return OptLazy(otherwise) as O; | ||
return this.mapFun(next, state.nextIndex()); | ||
} | ||
} | ||
export class MapPureIterator< | ||
T, | ||
A extends readonly unknown[], | ||
T2 | ||
> extends FastIteratorBase<T2> { | ||
constructor( | ||
readonly source: FastIterator<T>, | ||
readonly mapFun: (value: T, ...args: A) => T2, | ||
readonly args: A | ||
) { | ||
super(); | ||
} | ||
fastNext<O>(otherwise?: OptLazy<O>): T2 | O { | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) return OptLazy(otherwise) as O; | ||
return this.mapFun(next, ...this.args); | ||
} | ||
} |
export * from './constructors'; | ||
export * from './fast-iterator-custom'; | ||
export * from './stream-custom'; |
@@ -18,3 +18,2 @@ import { | ||
isFastIterator, | ||
FastIteratorBase, | ||
emptyFastIterator, | ||
@@ -50,2 +49,7 @@ FlatMapIterator, | ||
ZipWithIterator, | ||
AppendIterator, | ||
IndexedIterator, | ||
MapIterator, | ||
MapPureIterator, | ||
PrependIterator, | ||
} from '@rimbu/stream/custom'; | ||
@@ -588,16 +592,2 @@ import { RimbuError, Token } from '@rimbu/base'; | ||
class PrependIterator<T> extends FastIteratorBase<T> { | ||
constructor(readonly source: FastIterator<T>, readonly item: OptLazy<T>) { | ||
super(); | ||
} | ||
prependDone = false; | ||
fastNext<O>(otherwise?: OptLazy<O>): T | O { | ||
if (this.prependDone) return this.source.fastNext(otherwise!); | ||
this.prependDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
class PrependStream<T> extends StreamBase<T> { | ||
@@ -638,23 +628,2 @@ constructor(readonly source: Stream<T>, readonly item: OptLazy<T>) { | ||
class AppendIterator<T> extends FastIteratorBase<T> { | ||
constructor(readonly source: FastIterator<T>, readonly item: OptLazy<T>) { | ||
super(); | ||
} | ||
appendDone = false; | ||
fastNext<O>(otherwise?: OptLazy<O>): T | O { | ||
if (this.appendDone) return OptLazy(otherwise) as O; | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done !== value) return value; | ||
this.appendDone = true; | ||
return OptLazy(this.item); | ||
} | ||
} | ||
class AppendStream<T> extends StreamBase<T> { | ||
@@ -695,20 +664,2 @@ constructor(readonly source: Stream<T>, readonly item: OptLazy<T>) { | ||
class IndexedIterator<T> extends FastIteratorBase<[number, T]> { | ||
index: number; | ||
constructor(readonly source: FastIterator<T>, readonly startIndex = 0) { | ||
super(); | ||
this.index = startIndex; | ||
} | ||
fastNext<O>(otherwise?: OptLazy<O>): [number, T] | O { | ||
const done = Symbol('Done'); | ||
const value = this.source.fastNext(done); | ||
if (done === value) return OptLazy(otherwise) as O; | ||
return [this.index++, value]; | ||
} | ||
} | ||
class IndexedStream<T> extends StreamBase<[number, T]> { | ||
@@ -731,26 +682,2 @@ constructor(readonly source: Stream<T>, readonly startIndex: number) { | ||
class MapIterator<T, T2> extends FastIteratorBase<T2> { | ||
constructor( | ||
readonly source: FastIterator<T>, | ||
readonly mapFun: (value: T, index: number) => T2 | ||
) { | ||
super(); | ||
} | ||
readonly state = TraverseState(); | ||
fastNext<O>(otherwise?: OptLazy<O>): T2 | O { | ||
const state = this.state; | ||
if (state.halted) return OptLazy(otherwise) as O; | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) return OptLazy(otherwise) as O; | ||
return this.mapFun(next, state.nextIndex()); | ||
} | ||
} | ||
class MapStream<T, T2> extends StreamBase<T2> { | ||
@@ -800,25 +727,2 @@ constructor( | ||
class MapPureIterator< | ||
T, | ||
A extends readonly unknown[], | ||
T2 | ||
> extends FastIteratorBase<T2> { | ||
constructor( | ||
readonly source: FastIterator<T>, | ||
readonly mapFun: (value: T, ...args: A) => T2, | ||
readonly args: A | ||
) { | ||
super(); | ||
} | ||
fastNext<O>(otherwise?: OptLazy<O>): T2 | O { | ||
const done = Symbol('Done'); | ||
const next = this.source.fastNext(done); | ||
if (done === next) return OptLazy(otherwise) as O; | ||
return this.mapFun(next, ...this.args); | ||
} | ||
} | ||
class MapPureStream< | ||
@@ -825,0 +729,0 @@ T, |
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 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
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
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
1075807
21150