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.5.11 to 0.6.0

12

dist/main/constructors.js

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

if (min >= max)
common_1.Err.msg('min should be smaller than max');
common_1.ErrBase.msg('min should be smaller than max');
return new stream_custom_1.FromStream(function () { return new RandomIntIterator(min, max); });

@@ -522,3 +522,3 @@ }

_this.endIndex = endIndex;
_this.i = _this.startIndex;
_this.i = startIndex;
return _this;

@@ -560,3 +560,3 @@ }

_this.reversed = reversed;
_this.length = _this.endIndex - _this.startIndex + 1;
_this.length = endIndex - startIndex + 1;
return _this;

@@ -836,3 +836,3 @@ }

_this.delta = delta;
_this.state = _this.start;
_this.state = start;
return _this;

@@ -860,3 +860,3 @@ }

_this.delta = delta;
_this.state = _this.start;
_this.state = start;
return _this;

@@ -910,3 +910,3 @@ }

_this.max = max;
_this.width = _this.max - _this.min;
_this.width = max - min;
return _this;

@@ -913,0 +913,0 @@ }

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -341,4 +340,4 @@ exports.FromIterable = exports.FromStream = exports.StreamBase = exports.FastIteratorBase = void 0;

};
StreamBase.prototype.join = function (_b) {
var _c = _b === void 0 ? {} : _b, _d = _c.sep, sep = _d === void 0 ? '' : _d, _e = _c.start, start = _e === void 0 ? '' : _e, _f = _c.end, end = _f === void 0 ? '' : _f, _g = _c.valueToString, valueToString = _g === void 0 ? String : _g;
StreamBase.prototype.join = function (_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.sep, sep = _c === void 0 ? '' : _c, _d = _b.start, start = _d === void 0 ? '' : _d, _e = _b.end, end = _e === void 0 ? '' : _e, _f = _b.valueToString, valueToString = _f === void 0 ? String : _f;
var done = Symbol('Done');

@@ -355,4 +354,4 @@ var iterator = this[Symbol.iterator]();

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

@@ -512,3 +511,3 @@ };

_this.createIterator = createIterator;
_this[_a] = _this.createIterator;
_this[Symbol.iterator] = createIterator;
return _this;

@@ -519,3 +518,3 @@ }

exports.FromStream = FromStream;
_a = Symbol.iterator;
Symbol.iterator;
var PrependIterator = /** @class */ (function (_super) {

@@ -628,3 +627,3 @@ tslib_1.__extends(PrependIterator, _super);

_this.startIndex = startIndex;
_this.index = _this.startIndex;
_this.index = startIndex;
return _this;

@@ -784,5 +783,5 @@ }

_this.state = common_1.TraverseState();
_this.iterator = _this.source[Symbol.iterator]();
_this.done = false;
_this.currentIterator = null;
_this.iterator = _this.source[Symbol.iterator]();
return _this;

@@ -829,4 +828,4 @@ }

_this.otherSources = otherSources;
_this.iterator = _this.source[Symbol.iterator]();
_this.sourceIndex = 0;
_this.iterator = source[Symbol.iterator]();
return _this;

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

_this.amount = amount;
_this.remain = _this.amount;
_this.remain = amount;
return _this;

@@ -1305,5 +1304,5 @@ }

_this.amount = amount;
_this.iterator = _this.source[Symbol.iterator]();
_this.remain = _this.amount;
_this.isEmpty = true;
_this.iterator = source[Symbol.iterator]();
_this.remain = amount;
return _this;

@@ -1478,6 +1477,6 @@ }

_this.index = 0;
_this.state = common_1.Reducer.Init(_this.reducer.init);
_this.halt = function () {
_this.halted = true;
};
_this.state = common_1.Reducer.Init(reducer.init);
return _this;

@@ -1519,9 +1518,7 @@ }

_this.index = 0;
_this.state = _this.reducers.map(function (d) { return common_1.Reducer.Init(d.init); });
_this.done = _this.state.map(function (_, i) {
return function () {
_this.done[i] = null;
};
});
_this.isDone = false;
_this.state = reducers.map(function (d) { return common_1.Reducer.Init(d.init); });
_this.done = _this.state.map(function (_, i) { return function () {
_this.done[i] = null;
}; });
return _this;

@@ -1528,0 +1525,0 @@ }

import { RimbuError, Token } from '@rimbu/base';
import { Err, IndexRange, OptLazy, Range, Reducer, TraverseState, } from '@rimbu/common';
import { ErrBase, IndexRange, OptLazy, Range, Reducer, TraverseState, } from '@rimbu/common';
import { FastIterator, Stream, StreamSource } from './internal';

@@ -436,3 +436,3 @@ import { FastIteratorBase, FromIterable, FromStream, StreamBase, } from './stream-custom';

if (min >= max)
Err.msg('min should be smaller than max');
ErrBase.msg('min should be smaller than max');
return new FromStream(() => new RandomIntIterator(min, max));

@@ -456,3 +456,3 @@ }

this.endIndex = endIndex;
this.i = this.startIndex;
this.i = startIndex;
}

@@ -485,3 +485,3 @@ fastNext(otherwise) {

this.reversed = reversed;
this.length = this.endIndex - this.startIndex + 1;
this.length = endIndex - startIndex + 1;
}

@@ -738,3 +738,3 @@ [Symbol.iterator]() {

this.delta = delta;
this.state = this.start;
this.state = start;
}

@@ -758,3 +758,3 @@ fastNext(otherwise) {

this.delta = delta;
this.state = this.start;
this.state = start;
}

@@ -796,3 +796,3 @@ fastNext(otherwise) {

this.max = max;
this.width = this.max - this.min;
this.width = max - min;
}

@@ -799,0 +799,0 @@ fastNext() {

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

var _a;
import { CollectFun, Comp, Eq, OptLazy, Reducer, TraverseState, } from '@rimbu/common';

@@ -423,6 +422,6 @@ import { FastIterator, Stream, StreamSource } from './internal';

this.createIterator = createIterator;
this[_a] = this.createIterator;
this[Symbol.iterator] = createIterator;
}
}
_a = Symbol.iterator;
Symbol.iterator;
class PrependIterator extends FastIteratorBase {

@@ -519,3 +518,3 @@ constructor(source, item) {

this.startIndex = startIndex;
this.index = this.startIndex;
this.index = startIndex;
}

@@ -654,5 +653,5 @@ fastNext(otherwise) {

this.state = TraverseState();
this.iterator = this.source[Symbol.iterator]();
this.done = false;
this.currentIterator = null;
this.iterator = this.source[Symbol.iterator]();
}

@@ -693,4 +692,4 @@ fastNext(otherwise) {

this.otherSources = otherSources;
this.iterator = this.source[Symbol.iterator]();
this.sourceIndex = 0;
this.iterator = source[Symbol.iterator]();
}

@@ -1065,3 +1064,3 @@ fastNext(otherwise) {

this.amount = amount;
this.remain = this.amount;
this.remain = amount;
}

@@ -1101,5 +1100,5 @@ fastNext(otherwise) {

this.amount = amount;
this.iterator = this.source[Symbol.iterator]();
this.remain = this.amount;
this.isEmpty = true;
this.iterator = source[Symbol.iterator]();
this.remain = amount;
}

@@ -1253,6 +1252,6 @@ fastNext(otherwise) {

this.index = 0;
this.state = Reducer.Init(this.reducer.init);
this.halt = () => {
this.halted = true;
};
this.state = Reducer.Init(reducer.init);
}

@@ -1288,7 +1287,7 @@ fastNext(otherwise) {

this.index = 0;
this.state = this.reducers.map((d) => Reducer.Init(d.init));
this.isDone = false;
this.state = reducers.map((d) => Reducer.Init(d.init));
this.done = this.state.map((_, i) => () => {
this.done[i] = null;
});
this.isDone = false;
}

@@ -1295,0 +1294,0 @@ fastNext(otherwise) {

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

import { FastIterator } from './internal';
import type { FastIterator } from './internal';
/**

@@ -3,0 +3,0 @@ * An interface that extends the standard `Iterable` interface to return

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

import { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common';
import type { ArrayNonEmpty, CollectFun, Eq, OptLazy, Reducer, ToJSON, TraverseState } from '@rimbu/common';
import * as Constructors from './constructors';
import { FastIterable, Streamable, StreamSource } from './internal';
import type { FastIterable, Streamable, StreamSource } from './internal';
/**

@@ -5,0 +5,0 @@ * A possibly infinite sequence of elements of type T.

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

readonly createIterator: () => FastIterator<T>;
[Symbol.iterator]: () => FastIterator<T>;
constructor(createIterator: () => FastIterator<T>);
[Symbol.iterator]: () => FastIterator<T>;
}

@@ -98,0 +98,0 @@ export declare class FromIterable<T> extends StreamBase<T> {

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

import { Stream } from './internal';
import type { Stream } from './internal';
/**

@@ -3,0 +3,0 @@ * An object that can create a Stream of elements of type `T`

{
"name": "@rimbu/stream",
"version": "0.5.11",
"version": "0.6.0",
"description": "Efficient structure representing a sequence of elements, with powerful operations for TypeScript",

@@ -45,2 +45,3 @@ "keywords": [

"build": "yarn clean && yarn bundle",
"build:deno": "rimraf deno_dist ../../deno_dist/stream && denoify && cp ../../config/mod_ts_template deno_dist/mod.ts && mv deno_dist ../../deno_dist/stream",
"bundle": "yarn bundle:main && yarn bundle:module && yarn bundle:types",

@@ -50,3 +51,3 @@ "bundle:main": "tsc --p tsconfig.main.json",

"bundle:types": "tsc --p tsconfig.types.json",
"clean": "rimraf dist",
"clean": "rimraf dist deno_dist",
"format": "yarn format:base --write",

@@ -62,4 +63,4 @@ "format:base": "prettier \"{!CHANGELOG.md}|**/*.{ts,tsx,js,json,md}\"",

"dependencies": {
"@rimbu/base": "^0.5.9",
"@rimbu/common": "^0.5.9"
"@rimbu/base": "^0.6.0",
"@rimbu/common": "^0.6.0"
},

@@ -69,3 +70,6 @@ "publishConfig": {

},
"gitHead": "0158eaad0dec4503e92cb308af952869d68faad5"
"denoify": {
"replacer": "../../config/denoify-rimbu-replacer.js"
},
"gitHead": "dbcaad0cb6b1e31ffa64ca2739b9ddb0fc178ebc"
}
<p align="center">
<img src="../../assets/rimbu_logo.svg" />
<img src="https://github.com/rimbu-org/rimbu/raw/main/assets/rimbu_logo.svg" />
</p>

@@ -13,3 +13,3 @@

| ----------------- | ---------------------------------------------------------------------------------------------------- |
| `FastIterator<T>` | an Iterable that supports faster iterating than the `Iterable` type |
| `FastIterable<T>` | an Iterable that supports faster iterating than the `Iterable` type |
| `FastIterator<T>` | an Iterator that supports faster iterating than the `Iterator` type |

@@ -22,2 +22,4 @@ | `Stream<T>` | an Iterable-like structure that represents a source that can produce values of type T when requested |

Or [Try Me Out](https://codesandbox.io/s/rimbu-sandbox-d4tbk?previewwindow=console&view=split&editorsize=65&moduleview=1&module=/src/index.ts) in CodeSandBox.
## Installation

@@ -41,5 +43,3 @@

{
// ...
"compilerOptions": {
// ...
"skipLibCheck": true,

@@ -46,0 +46,0 @@ "noStrictGenericChecks": true

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

Eq,
Err,
ErrBase,
IndexRange,

@@ -544,3 +544,3 @@ OptLazy,

export function randomInt(min: number, max: number): Stream.NonEmpty<number> {
if (min >= max) Err.msg('min should be smaller than max');
if (min >= max) ErrBase.msg('min should be smaller than max');

@@ -569,2 +569,4 @@ return new FromStream(

class ArrayIterator<T> extends FastIteratorBase<T> {
i: number;
constructor(

@@ -576,6 +578,5 @@ readonly array: readonly T[],

super();
this.i = startIndex;
}
i = this.startIndex;
fastNext<O>(otherwise?: OptLazy<O>): T | O {

@@ -606,2 +607,4 @@ if (this.i > this.endIndex) return OptLazy(otherwise) as O;

class ArrayStream<T> extends StreamBase<T> {
readonly length: number;
constructor(

@@ -614,6 +617,5 @@ readonly array: readonly T[],

super();
this.length = endIndex - startIndex + 1;
}
readonly length = this.endIndex - this.startIndex + 1;
[Symbol.iterator](): FastIterator<T> {

@@ -948,2 +950,4 @@ if (!this.reversed) {

class RangeUpIterator extends FastIteratorBase<number> {
state: number;
constructor(

@@ -955,6 +959,6 @@ readonly start = 0,

super();
this.state = start;
}
state = this.start;
fastNext<O>(otherwise?: OptLazy<O>): number | O {

@@ -973,2 +977,4 @@ if (undefined !== this.end) {

class RangeDownIterator extends FastIteratorBase<number> {
state: number;
constructor(

@@ -980,6 +986,6 @@ readonly start = 0,

super();
this.state = start;
}
state = this.start;
fastNext<O>(otherwise?: OptLazy<O>): number | O {

@@ -1021,8 +1027,10 @@ if (undefined !== this.end) {

class RandomIntIterator extends FastIteratorBase<number> {
readonly width: number;
constructor(readonly min: number, readonly max: number) {
super();
this.width = max - min;
}
readonly width = this.max - this.min;
fastNext(): number {

@@ -1029,0 +1037,0 @@ return this.min + Math.round(Math.random() * this.width);

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

import { FastIterator } from './internal';
import type { FastIterator } from './internal';

@@ -3,0 +3,0 @@ /**

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

import {
import type {
ArrayNonEmpty,

@@ -11,3 +11,3 @@ CollectFun,

import * as Constructors from './constructors';
import { FastIterable, Streamable, StreamSource } from './internal';
import type { FastIterable, Streamable, StreamSource } from './internal';

@@ -14,0 +14,0 @@ /**

@@ -601,7 +601,8 @@ import {

export class FromStream<T> extends StreamBase<T> {
[Symbol.iterator]: () => FastIterator<T>;
constructor(readonly createIterator: () => FastIterator<T>) {
super();
this[Symbol.iterator] = createIterator;
}
[Symbol.iterator] = this.createIterator;
}

@@ -714,8 +715,9 @@

class IndexedIterator<T> extends FastIteratorBase<[number, T]> {
index: number;
constructor(readonly source: FastIterator<T>, readonly startIndex = 0) {
super();
this.index = startIndex;
}
index = this.startIndex;
fastNext<O>(otherwise?: OptLazy<O>): [number, T] | O {

@@ -887,2 +889,4 @@ const done = Symbol('Done');

class FlatMapIterator<T, T2> extends FastIteratorBase<T2> {
iterator: FastIterator<T>;
constructor(

@@ -897,2 +901,3 @@ readonly source: Stream<T>,

super();
this.iterator = this.source[Symbol.iterator]();
}

@@ -902,3 +907,2 @@

iterator = this.source[Symbol.iterator]();
done = false;

@@ -958,2 +962,4 @@ currentIterator: null | FastIterator<T2> = null;

class ConcatIterator<T> extends FastIteratorBase<T> {
iterator: FastIterator<T>;
constructor(

@@ -964,5 +970,6 @@ readonly source: Stream<T>,

super();
this.iterator = source[Symbol.iterator]();
}
iterator = this.source[Symbol.iterator]();
sourceIndex = 0;

@@ -1443,8 +1450,10 @@

class DropIterator<T> extends FastIteratorBase<T> {
remain: number;
constructor(readonly source: FastIterator<T>, readonly amount: number) {
super();
this.remain = amount;
}
remain = this.amount;
fastNext<O>(otherwise?: OptLazy<O>): T | O {

@@ -1481,8 +1490,12 @@ const source = this.source;

class RepeatIterator<T> extends FastIteratorBase<T> {
iterator: FastIterator<T>;
remain?: number;
constructor(readonly source: Stream<T>, readonly amount?: number) {
super();
this.iterator = source[Symbol.iterator]();
this.remain = amount;
}
iterator = this.source[Symbol.iterator]();
remain = this.amount;
isEmpty = true;

@@ -1665,2 +1678,4 @@

class ReduceIterator<I, R> extends FastIteratorBase<R> {
state: unknown;
constructor(

@@ -1671,2 +1686,4 @@ readonly source: FastIterator<I>,

super();
this.state = Reducer.Init(reducer.init);
}

@@ -1676,3 +1693,2 @@

index = 0;
state = Reducer.Init(this.reducer.init);

@@ -1708,2 +1724,5 @@ halt = (): void => {

class ReduceAllIterator<I, R> extends FastIteratorBase<R> {
readonly state: unknown[];
readonly done: ((() => void) | null)[];
constructor(

@@ -1714,2 +1733,7 @@ readonly source: FastIterator<I>,

super();
this.state = reducers.map((d: any): unknown => Reducer.Init(d.init));
this.done = this.state.map((_: any, i: any): (() => void) => (): void => {
this.done[i] = null;
});
}

@@ -1719,9 +1743,2 @@

index = 0;
state = this.reducers.map((d: any): unknown => Reducer.Init(d.init));
done: ((() => void) | null)[] = this.state.map(
(_: any, i: any): (() => void) =>
(): void => {
this.done[i] = null;
}
);
isDone = false;

@@ -1728,0 +1745,0 @@

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

import { Stream } from './internal';
import type { Stream } from './internal';

@@ -3,0 +3,0 @@ /**

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