Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@reactive-js/core

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reactive-js/core - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

liftable.d.ts

40

container.d.ts

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

import { Function1, Equality, Updater, Factory, Predicate, Reducer, TypePredicate } from './functions.js';
import { AbstractDisposable, DisposableLike } from './disposable.js';
import { Function1, Equality, Predicate, Updater, Factory, Reducer, Function2, Function3, Function4, Function5, TypePredicate } from './functions.js';
import { Option } from './option.js';

@@ -12,2 +13,6 @@

}
declare abstract class AbstractDisposableContainer extends AbstractDisposable implements ContainerLike {
get type(): this;
get T(): unknown;
}
declare type ContainerOf<C extends ContainerLike, T> = C extends {

@@ -31,2 +36,5 @@ readonly type: unknown;

}
interface DecodeWithCharset<C extends ContainerLike> extends Container<C> {
decodeWithCharset(charset?: string): ContainerOperator<C, ArrayBuffer, string>;
}
interface DistinctUntilChanged<C extends ContainerLike> extends Container<C> {

@@ -37,2 +45,5 @@ distinctUntilChanged<T>(options?: {

}
interface EverySatisfy<C extends ContainerLike> extends Container<C> {
everySatisfy<T>(predicate: Predicate<T>): ContainerOperator<C, T, boolean>;
}
interface FromArrayOptions {

@@ -79,2 +90,5 @@ readonly startIndex: Option<number>;

}
interface SomeSatisfy<C extends ContainerLike> extends Container<C> {
someSatisfy<T>(predicate: Predicate<T>): ContainerOperator<C, T, boolean>;
}
interface TakeFirst<C extends ContainerLike> extends Container<C> {

@@ -95,2 +109,19 @@ takeFirst<T>(options?: {

}
interface ThrowIfEmpty<C extends ContainerLike> extends Container<C> {
throwIfEmpty<T>(factory: Factory<unknown>): ContainerOperator<C, T, T>;
}
interface Using<C extends ContainerLike> extends Container<C> {
using<TResource extends DisposableLike, T>(resourceFactory: Factory<TResource>, containerFactory: Function1<TResource, ContainerOf<C, T>>): ContainerOf<C, T>;
using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, T>(resourceFactory: Factory<[TResource1, TResource2]>, containerFactory: Function2<TResource1, TResource2, ContainerOf<C, T>>): ContainerOf<C, T>;
using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, T>(resourceFactory: Factory<[TResource1, TResource2, TResource3]>, containerFactory: Function3<TResource1, TResource2, TResource3, ContainerOf<C, T>>): ContainerOf<C, T>;
using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, TResource4 extends DisposableLike, T>(resourceFactory: Factory<[TResource1, TResource2, TResource3, TResource4]>, containerFactory: Function4<TResource1, TResource2, TResource3, TResource4, ContainerOf<C, T>>): ContainerOf<C, T>;
using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, TResource4 extends DisposableLike, TResource5 extends DisposableLike, T>(resourceFactory: Factory<[
TResource1,
TResource2,
TResource3,
TResource4,
TResource5
]>, containerFactory: Function5<TResource1, TResource2, TResource3, TResource4, TResource5, ContainerOf<C, T>>): ContainerOf<C, T>;
using<TResource extends DisposableLike, T>(resourceFactory: Factory<TResource | readonly TResource[]>, runnableFactory: (...resources: readonly TResource[]) => ContainerOf<C, T>): ContainerOf<C, T>;
}
interface Zip<C extends ContainerLike> extends Container<C> {

@@ -110,2 +141,6 @@ zip<TA, TB>(a: ContainerOf<C, TA>, b: ContainerOf<C, TB>): ContainerOf<C, [TA, TB]>;

declare const empty: <C, T, O extends FromArrayOptions = FromArrayOptions>({ fromArray }: FromArray<C, O>, options?: Omit<Partial<O>, keyof FromArrayOptions> | undefined) => ContainerOf<C, T>;
declare const contains: <C, T>({ someSatisfy }: SomeSatisfy<C>, value: T, options?: {
readonly equality?: Equality<T> | undefined;
}) => ContainerOperator<C, T, boolean>;
declare const encodeUtf8: <C>(m: Using<C> & Map<C>) => ContainerOperator<C, string, Uint8Array>;
declare function endWith<C, T>(m: Concat<C> & FromArray<C>, value: T, ...values: readonly T[]): ContainerOperator<C, T, T>;

@@ -118,2 +153,3 @@ declare const fromOption: <C, T, O extends FromArrayOptions = FromArrayOptions>(m: FromArray<C, O>, options?: Omit<Partial<O>, keyof FromArrayOptions> | undefined) => Function1<Option<T>, ContainerOf<C, T>>;

declare const mapTo: <C, TA, TB>({ map }: Map<C>, value: TB) => ContainerOperator<C, TA, TB>;
declare const noneSatisfy: <C, T>({ everySatisfy }: EverySatisfy<C>, predicate: Predicate<T>) => ContainerOperator<C, T, boolean>;
declare function startWith<C, T>(m: Concat<C> & FromArray<C>, value: T, ...values: readonly T[]): ContainerOperator<C, T, T>;

@@ -123,2 +159,2 @@ declare const throws: <C, T, O extends FromArrayOptions = FromArrayOptions>(m: Map<C> & FromArray<C, O>, options?: Omit<Partial<O>, keyof FromArrayOptions> | undefined) => Function1<Factory<unknown>, ContainerOf<C, T>>;

export { AbstractContainer, Concat, ConcatAll, Container, ContainerLike, ContainerOf, ContainerOperator, DistinctUntilChanged, FromArray, FromArrayOptions, FromIterable, FromIterator, Generate, Keep, Map, Pairwise, Reduce, Repeat, Scan, SkipFirst, TakeFirst, TakeLast, TakeWhile, Zip, compute, concatMap, concatWith, empty, endWith, fromOption, fromValue, genMap, ignoreElements, keepType, mapTo, startWith, throws, zipWith };
export { AbstractContainer, AbstractDisposableContainer, Concat, ConcatAll, Container, ContainerLike, ContainerOf, ContainerOperator, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, FromArray, FromArrayOptions, FromIterable, FromIterator, Generate, Keep, Map, Pairwise, Reduce, Repeat, Scan, SkipFirst, SomeSatisfy, TakeFirst, TakeLast, TakeWhile, ThrowIfEmpty, Using, Zip, compute, concatMap, concatWith, contains, empty, encodeUtf8, endWith, fromOption, fromValue, genMap, ignoreElements, keepType, mapTo, noneSatisfy, startWith, throws, zipWith };

@@ -5,2 +5,3 @@ 'use strict';

var disposable = require('./disposable.js');
var functions = require('./functions.js');

@@ -11,8 +12,16 @@ var option = require('./option.js');

get type() {
return this;
return functions.raise();
}
get T() {
return undefined;
return functions.raise();
}
}
class AbstractDisposableContainer extends disposable.AbstractDisposable {
get type() {
return functions.raise();
}
get T() {
return functions.raise();
}
}
const compute = (m, options) => functions.compose(fromValue(m, options), m.map(functions.callWith()));

@@ -22,2 +31,7 @@ const concatMap = ({ map, concatAll }, mapper, options) => functions.compose(map(mapper), concatAll(options));

const empty = ({ fromArray }, options) => fromArray({ ...options })([]);
const contains = ({ someSatisfy }, value, options = {}) => {
const { equality = functions.strictEquality } = options;
return someSatisfy(functions.isEqualTo(value, equality));
};
const encodeUtf8 = (m) => obs => m.using(() => disposable.createDisposableValue(new TextEncoder(), functions.ignore), v => functions.pipe(obs, m.map(s => v.value.encode(s))));
function endWith(m, ...values) {

@@ -36,2 +50,3 @@ return concatWith(m, m.fromArray()(values));

const mapTo = ({ map }, value) => functions.pipe(value, functions.returns, map);
const noneSatisfy = ({ everySatisfy }, predicate) => everySatisfy(functions.compose(predicate, functions.negate));
function startWith(m, ...values) {

@@ -47,6 +62,9 @@ return container => functions.pipe(values, m.fromArray(), concatWith(m, container));

exports.AbstractContainer = AbstractContainer;
exports.AbstractDisposableContainer = AbstractDisposableContainer;
exports.compute = compute;
exports.concatMap = concatMap;
exports.concatWith = concatWith;
exports.contains = contains;
exports.empty = empty;
exports.encodeUtf8 = encodeUtf8;
exports.endWith = endWith;

@@ -59,4 +77,5 @@ exports.fromOption = fromOption;

exports.mapTo = mapTo;
exports.noneSatisfy = noneSatisfy;
exports.startWith = startWith;
exports.throws = throws;
exports.zipWith = zipWith;

6

disposable.js

@@ -32,3 +32,3 @@ 'use strict';

if (option.isSome(e)) {
teardown(e.cause);
teardown.call(parent, e.cause);
}

@@ -43,3 +43,3 @@ });

if (option.isNone(e)) {
teardown();
teardown.call(parent);
}

@@ -121,3 +121,3 @@ });

add(disposable) {
const disposables = this.disposables;
const { disposables } = this;
if (this.isDisposed) {

@@ -124,0 +124,0 @@ doDispose(this, disposable, this.error);

@@ -1,27 +0,31 @@

import { FromArray, FromArrayOptions, Keep, ContainerLike, Container, ContainerOf } from './container.js';
import { DisposableLike } from './disposable.js';
import { Equality, Function1, Factory, Updater, Predicate, Reducer } from './functions.js';
import { RunnableLike } from './runnable.js';
import { AbstractDisposableContainer, ConcatAll, FromArray, FromArrayOptions, FromIterator, FromIterable, Generate, Repeat, TakeLast, Zip, ContainerLike, Container, ContainerOf, Concat, DistinctUntilChanged, Keep, Map, Pairwise, Scan, SkipFirst, TakeFirst, TakeWhile, ThrowIfEmpty, Using } from './container.js';
import { Function1, Factory, Updater, Predicate, Equality, SideEffect1, Reducer } from './functions.js';
import { LiftedStateLike, AbstractLiftable, LiftableLike } from './liftable.js';
import { Option } from './option.js';
import { RunnableLike, ToRunnable } from './runnable.js';
/**
* Creates an EnumerableLike which yields all values from each source sequentially.
*/
declare function concat<T>(fst: EnumerableLike<T>, snd: EnumerableLike<T>, ...tail: readonly EnumerableLike<T>[]): EnumerableLike<T>;
declare abstract class Enumerator<T> extends AbstractDisposableContainer implements LiftedStateLike {
abstract get current(): T;
abstract get hasCurrent(): boolean;
abstract move(): boolean;
}
declare abstract class AbstractEnumerator<T> extends Enumerator<T> {
private _current;
private _hasCurrent;
constructor();
get current(): T;
set current(v: T);
get hasCurrent(): boolean;
reset(): void;
abstract move(): boolean;
}
declare const enumerate: <T>(enumerable: EnumerableLike<T>) => Enumerator<T>;
declare const current: <T>(enumerator: Enumerator<T>) => T;
declare const hasCurrent: <T>(enumerator: Enumerator<T>) => boolean;
declare const move: <T>(enumerator: Enumerator<T>) => boolean;
/**
* Returns an `ObservableLike` that emits all items emitted by the source that
* are distinct by comparison from the previous item.
*
* @param equals Optional equality function that is used to compare
* if an item is distinct from the previous item.
*/
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T> | undefined;
}) => EnumerableOperator<T, T>;
declare abstract class AbstractEnumerable<T> extends AbstractLiftable<Enumerator<T>> implements EnumerableLike<T> {
abstract enumerate(this: EnumerableLike<T>): Enumerator<T>;
}
declare const enumerate: <T>(enumerable: EnumerableLike<T>) => EnumeratorLike<T>;
declare const current: <T>(enumerator: EnumeratorLike<T>) => T;
declare const hasCurrent: <T>(enumerator: EnumeratorLike<T>) => boolean;
declare const move: <T>(enumerator: EnumeratorLike<T>) => boolean;
/**

@@ -31,2 +35,3 @@ * Converts a higher-order EnumerableLike into a first-order EnumerableLike.

declare const concatAll: <T>() => EnumerableOperator<EnumerableLike<T>, T>;
declare const concatAllT: ConcatAll<EnumerableLike<unknown>>;

@@ -51,2 +56,3 @@ /**

declare const fromIterator: <T, TReturn = any, TNext = unknown>() => Function1<Factory<Iterator<T, TReturn, TNext>>, EnumerableLike<T>>;
declare const fromIteratorT: FromIterator<EnumerableLike<unknown>>;
/**

@@ -58,2 +64,3 @@ * Converts a javascript Iterable to an EnumerableLike.

declare const fromIterable: <T>() => Function1<Iterable<T>, EnumerableLike<T>>;
declare const fromIterableT: FromIterable<EnumerableLike<unknown>>;

@@ -68,29 +75,5 @@ /**

declare const generate: <T>(generator: Updater<T>, initialValue: Factory<T>) => EnumerableLike<T>;
declare const generateT: Generate<EnumerableLike<unknown>>;
/**
* Returns an EnumerableOperator that applies `operator` to
* the EnumeratorLike returned by the source when enumerated.
*
* @param operator
*/
declare const lift: <TA, TB>(operator: EnumeratorOperator<TA, TB>) => EnumerableOperator<TA, TB>;
/**
* Returns an `EnumerableLike` that only emits items from the
* source that satisfy the specified type predicate.
*
* @param predicate The predicate function.
*/
declare const keep: <T>(predicate: Predicate<T>) => EnumerableOperator<T, T>;
declare const keepT: Keep<EnumerableLike<unknown>>;
/**
* Returns an `EnumerableLike` that applies the `mapper` function to each
* value emitted by the source.
*
* @param mapper The map function to apply each value. Must be a pure function.
*/
declare const map: <TA, TB>(mapper: Function1<TA, TB>) => EnumerableOperator<TA, TB>;
/**
* Returns an EnumerableLike that applies the predicate function each time the source

@@ -111,30 +94,5 @@ * completes to determine if the enumerable should be repeated.

declare function repeat<T>(): EnumerableOperator<T, T>;
declare const repeatT: Repeat<EnumerableLike<unknown>>;
/**
* Returns an EnumerableLike which yields values emitted by the source as long
* as each value satisfies the given predicate.
*
* @param predicate The predicate function.
*/
declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => EnumerableOperator<T, TAcc>;
/**
* Returns an EnumerableLike that skips the first `count` values emitted by the source.
*
* @param count The maximum number of values to emit.
*/
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => EnumerableOperator<T, T>;
/**
* Returns an EnumerableLike that only yields the first `count` values emitted by the source.
*
* @param count The maximum number of values to emit.
*/
declare const takeFirst: <T>(options?: {
readonly count?: number;
}) => EnumerableOperator<T, T>;
/**
* Returns an EnumerableLike that only yields the last `count` items yielded by the source.

@@ -147,14 +105,6 @@ *

}) => EnumerableOperator<T, T>;
declare const takeLastT: TakeLast<EnumerableLike<unknown>>;
/**
* Returns an EnumerableLike which yields values emitted by the source as long
* as each value satisfies the given predicate.
*
* @param predicate The predicate function.
*/
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => EnumerableOperator<T, T>;
declare const toRunnable: <T>() => Function1<EnumerableLike<T>, RunnableLike<T>>;
declare const toRunnableT: ToRunnable<EnumerableLike<unknown>>;

@@ -166,3 +116,3 @@ /**

declare function zipEnumerators(enumerators: readonly EnumeratorLike<unknown>[]): EnumeratorLike<readonly unknown[]>;
declare const zipEnumerators: (enumerators: readonly Enumerator<unknown>[]) => Enumerator<readonly unknown[]>;
declare function zip<TA, TB>(a: EnumerableLike<TA>, b: EnumerableLike<TB>): EnumerableLike<[TA, TB]>;

@@ -176,35 +126,16 @@ declare function zip<TA, TB, TC>(a: EnumerableLike<TA>, b: EnumerableLike<TB>, c: EnumerableLike<TC>): EnumerableLike<[TA, TB, TC]>;

declare function zip<TA, TB, TC, TD, TE, TF, TG, TH, TI>(a: EnumerableLike<TA>, b: EnumerableLike<TB>, c: EnumerableLike<TC>, d: EnumerableLike<TD>, e: EnumerableLike<TE>, f: EnumerableLike<TF>, g: EnumerableLike<TG>, h: EnumerableLike<TH>, i: EnumerableLike<TI>): EnumerableLike<[TA, TB, TC, TD, TE, TF, TG, TH, TI]>;
declare const zipT: Zip<EnumerableLike<unknown>>;
/**
* Inteface that enables iteration over a Container.
*/
interface EnumeratorLike<T> extends DisposableLike {
/**
* The current item, if present, at the current position of the enumerator.
*/
readonly current: T;
/**
* `true` if the current the enumerator has a current value, otherwise `false`.
*/
readonly hasCurrent: boolean;
/**
* Advances the enumerator to the next item.
*
* @returns `true` if the enumerator was successfully advanced to the next item, otherwise `false`.
*/
move(this: EnumeratorLike<T>): boolean;
}
/**
* Interface for iterating a Container of items.
*/
interface EnumerableLike<T> extends ContainerLike {
interface EnumerableLike<T> extends LiftableLike {
readonly T: unknown;
readonly type: EnumerableLike<this["T"]>;
readonly liftedStateType: Enumerator<this["T"]>;
/**
* Returns an `EnumeratorLike` to iterate through the Container.
*/
enumerate(this: EnumerableLike<T>): EnumeratorLike<T>;
enumerate(this: EnumerableLike<T>): Enumerator<T>;
}
/** A unary function that transforms an EnumeratorLike<TA> into a EnumeratorLike<TB> */
declare type EnumeratorOperator<TA, TB> = Function1<EnumeratorLike<TA>, EnumeratorLike<TB>>;
/** A unary function that transforms an EnumerableLike<TA> into a EnumerableLike<TB> */

@@ -218,3 +149,37 @@ declare type EnumerableOperator<TA, TB> = Function1<EnumerableLike<TA>, EnumerableLike<TB>>;

declare const type: EnumerableLike<unknown>;
/**
* Creates an EnumerableLike which yields all values from each source sequentially.
*/
declare function concat<T>(fst: EnumerableLike<T>, snd: EnumerableLike<T>, ...tail: readonly EnumerableLike<T>[]): EnumerableLike<T>;
declare const concatT: Concat<EnumerableLike<unknown>>;
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T>;
}) => EnumerableOperator<T, T>;
declare const distinctUntilChangedT: DistinctUntilChanged<EnumerableLike<unknown>>;
declare const keep: <T>(predicate: Predicate<T>) => EnumerableOperator<T, T>;
declare const keepT: Keep<EnumerableLike<unknown>>;
declare const map: <TA, TB>(mapper: Function1<TA, TB>) => EnumerableOperator<TA, TB>;
declare const mapT: Map<EnumerableLike<unknown>>;
declare const onNotify: <T>(onNotify: SideEffect1<T>) => EnumerableOperator<T, T>;
declare const pairwise: <T>() => EnumerableOperator<T, [Option<T>, T]>;
declare const pairwiseT: Pairwise<EnumerableLike<unknown>>;
declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => EnumerableOperator<T, TAcc>;
declare const scanT: Scan<EnumerableLike<unknown>>;
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => EnumerableOperator<T, T>;
declare const skipFirstT: SkipFirst<EnumerableLike<unknown>>;
declare const takeFirst: <T>(options?: {
readonly count?: number;
}) => EnumerableOperator<T, T>;
declare const takeFirstT: TakeFirst<EnumerableLike<unknown>>;
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => EnumerableOperator<T, T>;
declare const takeWhileT: TakeWhile<EnumerableLike<unknown>>;
declare const throwIfEmpty: <T>(factory: Factory<unknown>) => EnumerableOperator<T, T>;
declare const throwIfEmptyT: ThrowIfEmpty<EnumerableLike<unknown>>;
declare const using: Using<EnumerableLike<unknown>>["using"];
declare const usingT: Using<EnumerableLike<unknown>>;
export { EnumerableLike, EnumerableOperator, EnumeratorLike, EnumeratorOperator, ToEnumerable, concat, concatAll, current, distinctUntilChanged, enumerate, fromArray, fromArrayT, fromIterable, fromIterator, generate, hasCurrent, keep, keepT, lift, map, move, repeat, scan, skipFirst, takeFirst, takeLast, takeWhile, toEnumerable, toIterable, toRunnable, type, zip, zipEnumerators };
export { AbstractEnumerable, AbstractEnumerator, EnumerableLike, EnumerableOperator, Enumerator, ToEnumerable, concat, concatAll, concatAllT, concatT, current, distinctUntilChanged, distinctUntilChangedT, enumerate, fromArray, fromArrayT, fromIterable, fromIterableT, fromIterator, fromIteratorT, generate, generateT, hasCurrent, keep, keepT, map, mapT, move, onNotify, pairwise, pairwiseT, repeat, repeatT, scan, scanT, skipFirst, skipFirstT, takeFirst, takeFirstT, takeLast, takeLastT, takeWhile, takeWhileT, throwIfEmpty, throwIfEmptyT, toEnumerable, toIterable, toRunnable, toRunnableT, type, using, usingT, zip, zipEnumerators, zipT };

@@ -5,32 +5,59 @@ 'use strict';

var container = require('./container.js');
var disposable = require('./disposable.js');
var functions = require('./functions.js');
var disposable = require('./disposable.js');
var option = require('./option.js');
var container = require('./container.js');
var liftable = require('./liftable.js');
var runnable = require('./runnable.js');
var readonlyArray = require('./readonlyArray.js');
const enumerate = (enumerable) => enumerable.enumerate();
const current = (enumerator) => enumerator.current;
const hasCurrent = (enumerator) => enumerator.hasCurrent;
const move = (enumerator) => enumerator.move();
class AbstractDelegatingEnumerator {
constructor(delegate) {
this.delegate = delegate;
class Enumerator extends container.AbstractDisposableContainer {
}
class AbstractEnumerator extends Enumerator {
constructor() {
super();
this._current = option.none;
this._hasCurrent = false;
disposable.addTeardown(this, () => {
this.reset();
});
}
get error() {
return this.delegate.error;
get current() {
return this.hasCurrent ? this._current : functions.raise();
}
get isDisposed() {
return this.delegate.isDisposed;
set current(v) {
if (!this.isDisposed) {
this._current = v;
this._hasCurrent = true;
}
}
add(disposable) {
this.delegate.add(disposable);
get hasCurrent() {
return this._hasCurrent;
}
dispose(error) {
this.delegate.dispose(error);
reset() {
this._current = option.none;
this._hasCurrent = false;
}
}
class AbstractDelegatingEnumerator extends Enumerator {
constructor(delegate) {
super();
this.delegate = delegate;
}
get current() {
return this.delegate.current;
}
get hasCurrent() {
return this.delegate.hasCurrent;
}
}
const enumerate = (enumerable) => enumerable.enumerate();
const current = (enumerator) => enumerator.current;
const hasCurrent = (enumerator) => enumerator.hasCurrent;
const move = (enumerator) => enumerator.move();
class LiftedEnumerableLike extends container.AbstractContainer {
class AbstractEnumerable extends liftable.AbstractLiftable {
}
class LiftedEnumerable extends AbstractEnumerable {
constructor(src, operators) {

@@ -53,58 +80,57 @@ super();

const lift = (operator) => enumerable => {
const src = enumerable instanceof LiftedEnumerableLike ? enumerable.src : enumerable;
const allFunctions = enumerable instanceof LiftedEnumerableLike
const src = enumerable instanceof LiftedEnumerable ? enumerable.src : enumerable;
const allFunctions = enumerable instanceof LiftedEnumerable
? [...enumerable.operators, operator]
: [operator];
return new LiftedEnumerableLike(src, allFunctions);
return new LiftedEnumerable(src, allFunctions);
};
const liftT = {
variance: "covariant",
lift,
};
class ConcatAllEnumerator extends disposable.AbstractDisposable {
constructor(delegate) {
class ConcatAllEnumerator extends AbstractEnumerator {
constructor(delegate, enumerator) {
super();
this.delegate = delegate;
this.current = option.none;
this.hasCurrent = false;
this.enumerator = option.none;
disposable.addDisposableDisposeParentOnChildError(this, delegate);
disposable.addTeardown(this, () => {
this.enumerator = option.none;
});
this.enumerator = enumerator;
}
move() {
this.current = option.none;
this.hasCurrent = false;
const delegate = this.delegate;
if (option.isNone(this.enumerator) && delegate.move()) {
const enumerator = enumerate(delegate.current);
disposable.addDisposableDisposeParentOnChildError(this, enumerator);
this.enumerator = enumerator;
this.reset();
const { delegate, enumerator } = this;
if (enumerator.inner.isDisposed && delegate.move()) {
enumerator.inner = enumerate(delegate.current);
}
while (option.isSome(this.enumerator)) {
const enumerator = this.enumerator;
if (enumerator.move()) {
this.current = enumerator.current;
this.hasCurrent = true;
while (enumerator.inner instanceof Enumerator &&
!enumerator.inner.isDisposed) {
if (enumerator.inner.move()) {
this.current = enumerator.inner.current;
break;
}
else if (delegate.move()) {
this.enumerator = enumerate(delegate.current);
enumerator.inner = enumerate(delegate.current);
}
else {
this.enumerator = option.none;
this.dispose();
}
}
if (!this.hasCurrent) {
this.dispose();
}
return this.hasCurrent;
}
}
const operator = (enumerator) => new ConcatAllEnumerator(enumerator);
const _concatAll = lift(operator);
const operator = (delegate) => {
const inner = disposable.createSerialDisposable();
const enumerator = new ConcatAllEnumerator(delegate, inner);
disposable.bindDisposables(enumerator, inner);
disposable.addDisposableDisposeParentOnChildError(enumerator, delegate);
return enumerator;
};
/**
* Converts a higher-order EnumerableLike into a first-order EnumerableLike.
*/
const concatAll = () => _concatAll;
const concatAll = () => lift(operator);
const concatAllT = {
concatAll,
};
class ArrayEnumerator extends disposable.AbstractDisposable {
class ArrayEnumerator extends AbstractEnumerator {
constructor(array, index, endIndex) {

@@ -115,25 +141,20 @@ super();

this.endIndex = endIndex;
this.current = option.none;
this.hasCurrent = false;
}
move() {
const array = this.array;
let hasCurrent = false;
this.reset();
const { array } = this;
if (!this.isDisposed) {
this.index++;
const index = this.index;
if (index < this.endIndex) {
hasCurrent = true;
this.hasCurrent = true;
const { index, endIndex } = this;
if (index < endIndex) {
this.current = array[index];
}
else {
this.hasCurrent = false;
this.dispose();
}
}
return hasCurrent;
return this.hasCurrent;
}
}
class ArrayEnumerable extends container.AbstractContainer {
class ArrayEnumerable extends AbstractEnumerable {
constructor(values, startIndex, endIndex) {

@@ -165,42 +186,3 @@ super();

function concat(...enumerables) {
return functions.pipe(enumerables, fromArray(), concatAll());
}
class DistinctUntilChangedEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, equality) {
super(delegate);
this.equality = equality;
}
get current() {
return this.delegate.current;
}
get hasCurrent() {
return this.delegate.hasCurrent;
}
move() {
const prevCurrent = this.current;
const hadCurrent = this.hasCurrent;
while (this.delegate.move()) {
if (!hadCurrent || !this.equality(prevCurrent, this.delegate.current)) {
break;
}
}
return this.hasCurrent;
}
}
/**
* Returns an `ObservableLike` that emits all items emitted by the source that
* are distinct by comparison from the previous item.
*
* @param equals Optional equality function that is used to compare
* if an item is distinct from the previous item.
*/
const distinctUntilChanged = (options = {}) => {
const { equality = functions.strictEquality } = options;
const operator = (enumerator) => new DistinctUntilChangedEnumerator(enumerator, equality);
return lift(operator);
};
class IteratorEnumerator extends disposable.AbstractDisposable {
class IteratorEnumerator extends Enumerator {
constructor(iterator) {

@@ -228,3 +210,3 @@ super();

}
class IteratorEnumerable extends container.AbstractContainer {
class IteratorEnumerable extends AbstractEnumerable {
constructor(f) {

@@ -248,2 +230,5 @@ super();

const fromIterator = () => _fromIterator;
const fromIteratorT = {
fromIterator,
};
const _fromIterable = (iterable) => _fromIterator(() => iterable[Symbol.iterator]());

@@ -256,18 +241,16 @@ /**

const fromIterable = () => _fromIterable;
const fromIterableT = {
fromIterable,
};
class GenerateEnumerator extends disposable.AbstractDisposable {
class GenerateEnumerator extends AbstractEnumerator {
constructor(f, acc) {
super();
this.f = f;
this.hasCurrent = false;
this.current = acc;
}
move() {
if (this.isDisposed) {
this.hasCurrent = false;
}
else {
if (!this.isDisposed) {
try {
this.current = this.f(this.current);
this.hasCurrent = true;
}

@@ -281,3 +264,3 @@ catch (cause) {

}
class GenerateEnumerable extends container.AbstractContainer {
class GenerateEnumerable extends AbstractEnumerable {
constructor(f, acc) {

@@ -300,74 +283,7 @@ super();

const generate = (generator, initialValue) => new GenerateEnumerable(generator, initialValue);
class KeepEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, predicate) {
super(delegate);
this.predicate = predicate;
}
get current() {
return this.delegate.current;
}
get hasCurrent() {
return this.delegate.hasCurrent;
}
move() {
const delegate = this.delegate;
const predicate = this.predicate;
try {
while (delegate.move() && !predicate(delegate.current)) { }
}
catch (cause) {
this.dispose({ cause });
}
return this.hasCurrent;
}
}
/**
* Returns an `EnumerableLike` that only emits items from the
* source that satisfy the specified type predicate.
*
* @param predicate The predicate function.
*/
const keep = (predicate) => {
const operator = (enumerator) => new KeepEnumerator(enumerator, predicate);
return lift(operator);
const generateT = {
generate,
};
const keepT = {
keep,
};
class MapEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, mapper) {
super(delegate);
this.mapper = mapper;
this.current = option.none;
this.hasCurrent = false;
}
move() {
this.current = option.none;
this.hasCurrent = false;
try {
if (this.delegate.move()) {
this.current = this.mapper(this.delegate.current);
this.hasCurrent = true;
}
}
catch (cause) {
this.hasCurrent = false;
}
return this.hasCurrent;
}
}
/**
* Returns an `EnumerableLike` that applies the `mapper` function to each
* value emitted by the source.
*
* @param mapper The map function to apply each value. Must be a pure function.
*/
const map = (mapper) => {
const operator = (enumerator) => new MapEnumerator(enumerator, mapper);
return lift(operator);
};
class RepeatEnumerator extends disposable.AbstractDisposable {
class RepeatEnumerator extends Enumerator {
constructor(src, shouldRepeat) {

@@ -378,26 +294,31 @@ super();

this.count = 0;
this.enumerator = enumerate(src);
disposable.addDisposableDisposeParentOnChildError(this, this.enumerator);
}
get current() {
return this.enumerator.current;
var _a, _b;
return this.hasCurrent ? (_b = (_a = this.enumerator) === null || _a === void 0 ? void 0 : _a.current) !== null && _b !== void 0 ? _b : functions.raise() : functions.raise();
}
get hasCurrent() {
return this.enumerator.hasCurrent;
var _a, _b;
return (_b = (_a = this.enumerator) === null || _a === void 0 ? void 0 : _a.hasCurrent) !== null && _b !== void 0 ? _b : false;
}
move() {
if (!this.enumerator.move()) {
if (option.isNone(this.enumerator)) {
this.enumerator = enumerate(this.src);
disposable.addDisposableDisposeParentOnChildError(this, this.enumerator);
}
while (!this.enumerator.move()) {
this.count++;
let doRepeat = false;
try {
doRepeat = this.shouldRepeat(this.count);
if (this.shouldRepeat(this.count)) {
this.enumerator = enumerate(this.src);
disposable.addDisposableDisposeParentOnChildError(this, this.enumerator);
}
else {
break;
}
}
catch (cause) {
this.dispose({ cause });
break;
}
if (doRepeat) {
this.enumerator = enumerate(this.src);
disposable.addDisposableDisposeParentOnChildError(this, this.enumerator);
this.enumerator.move();
}
}

@@ -407,3 +328,3 @@ return this.hasCurrent;

}
class RepeatEnumerable extends container.AbstractContainer {
class RepeatEnumerable extends AbstractEnumerable {
constructor(src, shouldRepeat) {

@@ -426,105 +347,8 @@ super();

}
class ScanEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, reducer, current) {
super(delegate);
this.reducer = reducer;
this.current = current;
}
get hasCurrent() {
return this.delegate.hasCurrent;
}
move() {
const delegate = this.delegate;
if (delegate.move()) {
try {
this.current = this.reducer(this.current, this.delegate.current);
}
catch (cause) {
this.dispose({ cause });
}
}
return this.hasCurrent;
}
}
/**
* Returns an EnumerableLike which yields values emitted by the source as long
* as each value satisfies the given predicate.
*
* @param predicate The predicate function.
*/
const scan = (reducer, initialValue) => {
const operator = (observer) => new ScanEnumerator(observer, reducer, initialValue());
return lift(operator);
const repeatT = {
repeat,
};
class SkipFirstEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, skipCount) {
super(delegate);
this.skipCount = skipCount;
this.count = 0;
}
get current() {
return this.delegate.current;
}
get hasCurrent() {
return this.delegate.hasCurrent;
}
move() {
const skipCount = this.skipCount;
for (let count = this.count; count < skipCount; count++) {
if (!this.delegate.move()) {
break;
}
}
this.count = skipCount;
return this.delegate.move();
}
}
/**
* Returns an EnumerableLike that skips the first `count` values emitted by the source.
*
* @param count The maximum number of values to emit.
*/
const skipFirst = (options = {}) => {
const { count = 1 } = options;
const operator = (enumerator) => new SkipFirstEnumerator(enumerator, count);
return lift(operator);
};
class TakeFirstEnumerator extends AbstractDelegatingEnumerator {
class TakeLastEnumerator extends Enumerator {
constructor(delegate, maxCount) {
super(delegate);
this.maxCount = maxCount;
this.count = 0;
this.hasCurrent = false;
}
get current() {
return this.delegate.current;
}
move() {
this.hasCurrent = false;
if (this.count < this.maxCount && this.delegate.move()) {
this.count++;
this.hasCurrent = this.delegate.hasCurrent;
}
else {
this.dispose();
}
return this.hasCurrent;
}
}
/**
* Returns an EnumerableLike that only yields the first `count` values emitted by the source.
*
* @param count The maximum number of values to emit.
*/
const takeFirst = (options = {}) => {
const { count = 1 } = options;
const operator = (enumerator) => new TakeFirstEnumerator(enumerator, count);
return lift(operator);
};
class TakeLastEnumerator extends disposable.AbstractDisposable {
constructor(delegate, maxCount) {
super();

@@ -534,7 +358,6 @@ this.delegate = delegate;

this.enumerator = option.none;
disposable.addDisposableDisposeParentOnChildError(this, delegate);
}
get current() {
var _a;
return (_a = this.enumerator) === null || _a === void 0 ? void 0 : _a.current;
return this.hasCurrent ? (_a = this.enumerator) === null || _a === void 0 ? void 0 : _a.current : functions.raise();
}

@@ -546,4 +369,4 @@ get hasCurrent() {

move() {
const delegate = this.delegate;
if (option.isNone(this.enumerator)) {
const { delegate } = this;
if (!this.isDisposed && option.isNone(this.enumerator)) {
const last = [];

@@ -559,3 +382,5 @@ while (delegate.move()) {

}
this.enumerator.move();
if (option.isSome(this.enumerator)) {
this.enumerator.move();
}
return this.hasCurrent;

@@ -571,3 +396,7 @@ }

const { count = 1 } = options;
const operator = (enumerator) => new TakeLastEnumerator(enumerator, count);
const operator = (delegate) => {
const enumerator = new TakeLastEnumerator(delegate, count);
disposable.addDisposableDisposeParentOnChildError(enumerator, delegate);
return enumerator;
};
return enumerable => count > 0

@@ -578,50 +407,4 @@ ? functions.pipe(enumerable, lift(operator))

};
class TakeWhileEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, predicate, inclusive) {
super(delegate);
this.predicate = predicate;
this.inclusive = inclusive;
this.state = 0;
}
get current() {
return this.delegate.current;
}
get hasCurrent() {
return this.state < 2 && this.delegate.hasCurrent;
}
move() {
const delegate = this.delegate;
const state = this.state;
if (state === 0 && delegate.move()) {
try {
const satisfiesPredicate = this.predicate(delegate.current);
if (!satisfiesPredicate && this.inclusive) {
this.state++;
}
else if (!satisfiesPredicate) {
this.state = 2;
}
}
catch (cause) {
this.dispose({ cause });
this.state = 2;
}
}
else if (state < 2 && this.inclusive) {
this.state++;
}
return this.hasCurrent;
}
}
/**
* Returns an EnumerableLike which yields values emitted by the source as long
* as each value satisfies the given predicate.
*
* @param predicate The predicate function.
*/
const takeWhile = (predicate, options = {}) => {
const { inclusive = false } = options;
const operator = (observer) => new TakeWhileEnumerator(observer, predicate, inclusive);
return lift(operator);
const takeLastT = {
takeLast,
};

@@ -642,2 +425,5 @@

const toRunnable = () => _toRunnable;
const toRunnableT = {
toRunnable,
};

@@ -667,29 +453,30 @@ class EnumerableIterable {

const allHaveCurrent = (enumerators) => functions.pipe(enumerators, readonlyArray.everySatisfy(hasCurrent));
class ZipEnumerator extends disposable.AbstractDisposable {
class ZipEnumerator extends AbstractEnumerator {
constructor(enumerators) {
super();
this.enumerators = enumerators;
this.current = [];
this.hasCurrent = false;
for (const enumerator of enumerators) {
disposable.addDisposableDisposeParentOnChildError(this, enumerator);
}
}
move() {
this.hasCurrent = false;
const enumerators = this.enumerators;
moveAll(enumerators);
const hasCurrent = allHaveCurrent(enumerators);
this.hasCurrent = hasCurrent;
this.current = hasCurrent ? functions.pipe(enumerators, readonlyArray.map(current)) : [];
if (!hasCurrent) {
this.dispose();
this.reset();
if (!this.isDisposed) {
const { enumerators } = this;
moveAll(enumerators);
if (allHaveCurrent(enumerators)) {
this.current = functions.pipe(enumerators, readonlyArray.map(current));
}
else {
this.dispose();
}
}
return hasCurrent;
return this.hasCurrent;
}
}
function zipEnumerators(enumerators) {
return new ZipEnumerator(enumerators);
}
class ZipEnumerable extends container.AbstractContainer {
const zipEnumerators = (enumerators) => {
const enumerator = new ZipEnumerator(enumerators);
for (const delegate of enumerators) {
disposable.addDisposableDisposeParentOnChildError(enumerator, delegate);
}
return enumerator;
};
class ZipEnumerable extends AbstractEnumerable {
constructor(enumerables) {

@@ -710,10 +497,273 @@ super();

}
const zipT = {
zip,
};
const toEnumerable = () => functions.identity;
const type = undefined;
function concat(...enumerables) {
return functions.pipe(enumerables, fromArray(), concatAll());
}
const concatT = {
concat,
};
const distinctUntilChanged = liftable.createDistinctUntilChangedLiftedOperator(liftT, class DistinctUntilChangedEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, equality) {
super(delegate);
this.equality = equality;
}
move() {
const hadCurrent = this.hasCurrent;
const prevCurrent = hadCurrent ? this.current : option.none;
try {
while (this.delegate.move()) {
if (!hadCurrent ||
!this.equality(prevCurrent, this.delegate.current)) {
break;
}
}
}
catch (cause) {
functions.pipe(this, disposable.dispose({ cause }));
}
return this.hasCurrent;
}
});
const distinctUntilChangedT = {
distinctUntilChanged,
};
const keep = liftable.createKeepLiftedOperator(liftT, class KeepEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, predicate) {
super(delegate);
this.predicate = predicate;
}
move() {
const { delegate, predicate } = this;
try {
while (delegate.move() && !predicate(delegate.current)) { }
}
catch (cause) {
functions.pipe(this, disposable.dispose({ cause }));
}
return this.hasCurrent;
}
});
const keepT = {
keep,
};
const map = liftable.createMapLiftedOperator(liftT, class MapEnumerator extends AbstractEnumerator {
constructor(delegate, mapper) {
super();
this.delegate = delegate;
this.mapper = mapper;
}
move() {
this.reset();
if (this.delegate.move()) {
try {
this.current = this.mapper(this.delegate.current);
}
catch (cause) {
functions.pipe(this, disposable.dispose({ cause }));
}
}
return this.hasCurrent;
}
});
const mapT = {
map,
};
const onNotify = liftable.createOnNotifyLiftedOperator(liftT, class OnNotifyEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, onNotify) {
super(delegate);
this.onNotify = onNotify;
}
move() {
const { delegate } = this;
if (delegate.move()) {
try {
this.onNotify(this.current);
}
catch (cause) {
functions.pipe(this, disposable.dispose({ cause }));
}
}
return this.hasCurrent;
}
});
const pairwise = liftable.createPairwiseLiftedOperator(liftT, class PairwiseEnumerator extends AbstractEnumerator {
constructor(delegate) {
super();
this.delegate = delegate;
}
move() {
const prev = (this.hasCurrent ? this.current : [])[1];
this.reset();
const { delegate } = this;
if (delegate.move()) {
const { current } = delegate;
this.current = [prev, current];
}
return this.hasCurrent;
}
});
const pairwiseT = {
pairwise,
};
const scan = liftable.createScanLiftedOperator(liftT, class ScanEnumerator extends AbstractEnumerator {
constructor(delegate, reducer, current) {
super();
this.delegate = delegate;
this.reducer = reducer;
this.current = current;
}
move() {
const acc = this.hasCurrent ? this.current : option.none;
this.reset();
const { delegate, reducer } = this;
if (option.isSome(acc) && delegate.move()) {
try {
this.current = reducer(acc, delegate.current);
}
catch (cause) {
functions.pipe(this, disposable.dispose({ cause }));
}
}
return this.hasCurrent;
}
});
const scanT = {
scan,
};
const skipFirst = liftable.createSkipFirstLiftedOperator(liftT, class SkipFirstEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, skipCount) {
super(delegate);
this.skipCount = skipCount;
this.count = 0;
}
move() {
const { delegate, skipCount } = this;
for (let { count } = this; count < skipCount; count++) {
if (!delegate.move()) {
break;
}
}
this.count = skipCount;
return delegate.move();
}
});
const skipFirstT = {
skipFirst,
};
const takeFirst = liftable.createTakeFirstLiftdOperator({ ...fromArrayT, ...liftT }, class TakeFirstEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, maxCount) {
super(delegate);
this.maxCount = maxCount;
this.count = 0;
}
get current() {
return this.delegate.current;
}
move() {
if (this.count < this.maxCount) {
this.count++;
this.delegate.move();
}
else {
this.dispose();
}
return this.hasCurrent;
}
});
const takeFirstT = {
takeFirst,
};
const takeWhile = liftable.createTakeWhileLiftedOperator(liftT, class TakeWhileEnumerator extends AbstractDelegatingEnumerator {
constructor(delegate, predicate, inclusive) {
super(delegate);
this.predicate = predicate;
this.inclusive = inclusive;
this.done = false;
}
move() {
const { delegate, inclusive, predicate } = this;
if (this.done && !this.isDisposed) {
functions.pipe(this, disposable.dispose());
}
else if (delegate.move()) {
const { current } = delegate;
try {
const satisfiesPredicate = predicate(current);
if (!satisfiesPredicate && inclusive) {
this.done = true;
}
else if (!satisfiesPredicate) {
functions.pipe(this, disposable.dispose());
}
}
catch (cause) {
functions.pipe(this, disposable.dispose({ cause }));
}
}
return this.hasCurrent;
}
});
const takeWhileT = {
takeWhile,
};
const throwIfEmpty = liftable.createThrowIfEmptyLiftedOperator(liftT, class ThrowIfEmptyEnumerator extends AbstractDelegatingEnumerator {
constructor() {
super(...arguments);
this.isEmpty = true;
}
move() {
if (this.move()) {
this.isEmpty = false;
}
return this.hasCurrent;
}
});
const throwIfEmptyT = {
throwIfEmpty,
};
class UsingEnumerable extends AbstractEnumerable {
constructor(resourceFactory, sourceFactory) {
super();
this.resourceFactory = resourceFactory;
this.sourceFactory = sourceFactory;
}
enumerate() {
try {
const resources = this.resourceFactory();
const resourcesArray = Array.isArray(resources) ? resources : [resources];
const source = this.sourceFactory(...resourcesArray);
const enumerator = enumerate(source);
for (const r of resourcesArray) {
disposable.addDisposableDisposeParentOnChildError(enumerator, r);
}
return enumerator;
}
catch (cause) {
const enumerator = functions.pipe(container.empty(fromArrayT), enumerate);
enumerator.dispose({ cause });
return enumerator;
}
}
}
const _using = (resourceFactory, enumerableFactory) => new UsingEnumerable(resourceFactory, enumerableFactory);
const using = _using;
const usingT = {
using,
};
exports.AbstractEnumerable = AbstractEnumerable;
exports.AbstractEnumerator = AbstractEnumerator;
exports.Enumerator = Enumerator;
exports.concat = concat;
exports.concatAll = concatAll;
exports.concatAllT = concatAllT;
exports.concatT = concatT;
exports.current = current;
exports.distinctUntilChanged = distinctUntilChanged;
exports.distinctUntilChangedT = distinctUntilChangedT;
exports.enumerate = enumerate;

@@ -723,21 +773,39 @@ exports.fromArray = fromArray;

exports.fromIterable = fromIterable;
exports.fromIterableT = fromIterableT;
exports.fromIterator = fromIterator;
exports.fromIteratorT = fromIteratorT;
exports.generate = generate;
exports.generateT = generateT;
exports.hasCurrent = hasCurrent;
exports.keep = keep;
exports.keepT = keepT;
exports.lift = lift;
exports.map = map;
exports.mapT = mapT;
exports.move = move;
exports.onNotify = onNotify;
exports.pairwise = pairwise;
exports.pairwiseT = pairwiseT;
exports.repeat = repeat;
exports.repeatT = repeatT;
exports.scan = scan;
exports.scanT = scanT;
exports.skipFirst = skipFirst;
exports.skipFirstT = skipFirstT;
exports.takeFirst = takeFirst;
exports.takeFirstT = takeFirstT;
exports.takeLast = takeLast;
exports.takeLastT = takeLastT;
exports.takeWhile = takeWhile;
exports.takeWhileT = takeWhileT;
exports.throwIfEmpty = throwIfEmpty;
exports.throwIfEmptyT = throwIfEmptyT;
exports.toEnumerable = toEnumerable;
exports.toIterable = toIterable;
exports.toRunnable = toRunnable;
exports.toRunnableT = toRunnableT;
exports.type = type;
exports.using = using;
exports.usingT = usingT;
exports.zip = zip;
exports.zipEnumerators = zipEnumerators;
exports.zipT = zipT;
declare const __DEV__: boolean;
declare const warn: (message: string) => void;
declare const __DENO__: boolean;
export { __DENO__, __DEV__, warn };
export { __DENO__, __DEV__ };

@@ -6,7 +6,2 @@ 'use strict';

const __DEV__ = typeof process === "object" ? process.env.NODE_ENV !== "production" : false;
const warn = (message) => {
if (__DEV__) {
console.warn(message);
}
};
const __DENO__ = typeof Deno === "object";

@@ -16,2 +11,1 @@

exports.__DEV__ = __DEV__;
exports.warn = warn;

@@ -7,3 +7,3 @@ /// <reference types="node" />

import { DisposableValueLike } from './disposable.js';
import { StreamableLike, FlowMode, NotifyEvent, DoneEvent, StreamableOperator } from './streamable.js';
import { FlowableLike, FlowableSinkLike, StreamableOperator, FlowMode } from './streamable.js';
import { BrotliOptions, ZlibOptions } from 'zlib';

@@ -24,3 +24,3 @@

declare const createReadableIOSource: (factory: Factory<DisposableValueLike<Readable>>) => StreamableLike<FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const createReadableIOSource: (factory: Factory<DisposableValueLike<Readable>>) => FlowableLike<Uint8Array>;
declare const readFileIOSource: (path: fs.PathLike, options?: {

@@ -32,16 +32,16 @@ readonly flags?: string;

readonly highWaterMark?: number;
}) => StreamableLike<FlowMode, DoneEvent | NotifyEvent<Uint8Array>>;
}) => FlowableLike<Uint8Array>;
declare const createWritableIOSink: (factory: Factory<DisposableValueLike<Writable>>) => StreamableLike<NotifyEvent<Uint8Array> | DoneEvent, FlowMode>;
declare const createWritableIOSink: (factory: Factory<DisposableValueLike<Writable>>) => FlowableSinkLike<Uint8Array>;
declare const createDisposableNodeStream: <T extends Readable | Writable | Transform>(stream: T) => DisposableValueLike<T>;
declare const transform: (factory: Factory<DisposableValueLike<Transform>>) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const brotliDecompress: (options?: BrotliOptions) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const gunzip: (options?: ZlibOptions) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const inflate: (options?: ZlibOptions) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const brotliCompress: (options?: BrotliOptions) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const gzip: (options?: ZlibOptions) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const deflate: (options?: ZlibOptions) => StreamableOperator<FlowMode, NotifyEvent<Uint8Array> | DoneEvent, FlowMode, NotifyEvent<Uint8Array> | DoneEvent>;
declare const transform: (factory: Factory<DisposableValueLike<Transform>>) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
declare const brotliDecompress: (options?: BrotliOptions) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
declare const gunzip: (options?: ZlibOptions) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
declare const inflate: (options?: ZlibOptions) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
declare const brotliCompress: (options?: BrotliOptions) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
declare const gzip: (options?: ZlibOptions) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
declare const deflate: (options?: ZlibOptions) => StreamableOperator<FlowMode, Uint8Array, FlowMode, Uint8Array>;
export { bindNodeCallback, brotliCompress, brotliDecompress, createDisposableNodeStream, createReadableIOSource, createWritableIOSink, deflate, gunzip, gzip, inflate, readFileIOSource, transform };

@@ -50,18 +50,3 @@ 'use strict';

const createReadableEventsObservable = (readable) => observable.createObservable(dispatcher => {
const readableValue = readable.value;
const onData = functions.compose(streamable.notifyEvent, observable.dispatchTo(dispatcher));
readableValue.on("data", onData);
const onEnd = () => {
dispatcher.dispatch(streamable.doneEvent);
functions.pipe(dispatcher, disposable.dispose());
};
readableValue.on("end", onEnd);
disposable.addDisposable(readable, dispatcher);
disposable.addTeardown(dispatcher, _ => {
readableValue.removeListener("data", onData);
readableValue.removeListener("end", onEnd);
});
});
const createReadableAndSetupModeSubscription = (factory, mode) => (scheduler) => {
const createReadableIOSource = (factory) => streamable.createStreamable(mode => observable.createObservableWithScheduler(scheduler => {
const readable = factory();

@@ -80,50 +65,58 @@ const readableValue = readable.value;

}));
disposable.addDisposable(scheduler, readable);
disposable.addDisposableDisposeParentOnChildError(readable, modeSubscription);
return readable;
};
const createReadableIOSource = (factory) => streamable.createStreamable(mode => observable.using(createReadableAndSetupModeSubscription(factory, mode), createReadableEventsObservable));
return observable.createObservable(dispatcher => {
const readableValue = readable.value;
const onData = observable.dispatchTo(dispatcher);
readableValue.on("data", onData);
const onEnd = () => {
functions.pipe(dispatcher, disposable.dispose());
};
readableValue.on("end", onEnd);
disposable.addDisposable(readable, dispatcher);
disposable.addTeardown(dispatcher, _ => {
readableValue.removeListener("data", onData);
readableValue.removeListener("end", onEnd);
});
});
}));
const readFileIOSource = (path, options) => createReadableIOSource(() => functions.pipe(fs__default["default"].createReadStream(path, options), createDisposableNodeStream));
const NODE_JS_PAUSE_EVENT = "__REACTIVE_JS_NODE_WRITABLE_PAUSE__";
const createWritableEventsObservable = (writable) => observable.createObservable(dispatcher => {
const writableValue = writable.value;
const onDrain = functions.defer("resume", observable.dispatchTo(dispatcher));
writableValue.on("drain", onDrain);
const onFinish = functions.defer(dispatcher, disposable.dispose());
writableValue.on("finish", onFinish);
const onPause = functions.defer("pause", observable.dispatchTo(dispatcher));
writableValue.on(NODE_JS_PAUSE_EVENT, onPause);
disposable.addDisposable(writable, dispatcher);
disposable.addTeardown(dispatcher, _ => {
writableValue.removeListener("drain", onDrain);
writableValue.removeListener("finish", onFinish);
writableValue.removeListener(NODE_JS_PAUSE_EVENT, onPause);
});
dispatcher.dispatch("resume");
});
const createWritableAndSetupEventSubscription = (factory, events) => (scheduler) => {
const createWritableIOSink = (factory) => streamable.createStreamable(events => observable.createObservableWithScheduler(scheduler => {
const writable = factory();
const writableValue = writable.value;
const streamEventsSubscription = functions.pipe(events, observable.subscribe(scheduler, ev => {
switch (ev.type) {
case "notify":
// FIXME: when writing to an outgoing node ServerResponse with a UInt8Array
// node throws a type Error regarding expecting a Buffer, though the docs
// say a UInt8Array should be accepted. Need to file a bug.
if (!writableValue.write(Buffer.from(ev.data))) {
// Hack in a custom event here for pause request
writableValue.emit(NODE_JS_PAUSE_EVENT);
}
break;
case "done":
writableValue.end();
break;
// FIXME: when writing to an outgoing node ServerResponse with a UInt8Array
// node throws a type Error regarding expecting a Buffer, though the docs
// say a UInt8Array should be accepted. Need to file a bug.
if (!writableValue.write(Buffer.from(ev))) {
// Hack in a custom event here for pause request
writableValue.emit(NODE_JS_PAUSE_EVENT);
}
}));
disposable.addOnDisposedWithoutErrorTeardown(streamEventsSubscription, () => {
writableValue.end();
});
disposable.addDisposableDisposeParentOnChildError(writable, streamEventsSubscription);
return writable;
};
const createWritableIOSink = (factory) => streamable.createStreamable(events => observable.using(createWritableAndSetupEventSubscription(factory, events), createWritableEventsObservable));
disposable.addDisposable(scheduler, writable);
return observable.createObservable(dispatcher => {
const writableValue = writable.value;
const onDrain = functions.defer("resume", observable.dispatchTo(dispatcher));
writableValue.on("drain", onDrain);
const onFinish = functions.defer(dispatcher, disposable.dispose());
writableValue.on("finish", onFinish);
const onPause = functions.defer("pause", observable.dispatchTo(dispatcher));
writableValue.on(NODE_JS_PAUSE_EVENT, onPause);
disposable.addDisposable(writable, dispatcher);
disposable.addTeardown(dispatcher, _ => {
writableValue.removeListener("drain", onDrain);
writableValue.removeListener("finish", onFinish);
writableValue.removeListener(NODE_JS_PAUSE_EVENT, onPause);
});
dispatcher.dispatch("resume");
});
}));
const transform = (factory) => src => streamable.createStreamable(modeObs => observable.using(scheduler => {
const transform = (factory) => src => streamable.createStreamable(modeObs => observable.createObservableWithScheduler(scheduler => {
const transform = factory();

@@ -142,4 +135,5 @@ const transformSink = createWritableIOSink(

disposable.addDisposableDisposeParentOnChildError(transformReadableStream, modeSubscription);
disposable.addDisposable(scheduler, transformReadableStream);
return transformReadableStream;
}, functions.identity));
}));
const brotliDecompress = (options = {}) => transform(functions.defer(options, zlib.createBrotliDecompress, createDisposableNodeStream));

@@ -146,0 +140,0 @@ const gunzip = (options = {}) => transform(functions.defer(options, zlib.createGunzip, createDisposableNodeStream));

@@ -1,10 +0,34 @@

import { Concat, FromArray, FromIterator, Keep, Map, ConcatAll, Zip, ContainerLike } from './container.js';
import { AbstractDisposableContainer, Concat, FromArray, FromIterator, FromIterable, Using, Map, ConcatAll, Repeat, TakeFirst, Zip, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, Keep, Pairwise, Reduce, Scan, SkipFirst, SomeSatisfy, TakeLast, TakeWhile, ThrowIfEmpty } from './container.js';
import { DisposableLike, DisposableOrTeardown } from './disposable.js';
import { SideEffect1, Factory, Function1, Function2, Function3, Function4, Function5, Function6, SideEffect, SideEffect2, SideEffect3, SideEffect4, SideEffect5, SideEffect6, Updater, Equality, Predicate, Reducer } from './functions.js';
import { SchedulerLike, VirtualTimeSchedulerLike } from './scheduler.js';
import { SinkLike } from './sink.js';
import { SideEffect1, Factory, Function1, Function2, Function3, Function4, Function5, Function6, SideEffect, SideEffect2, SideEffect3, SideEffect4, SideEffect5, SideEffect6, Updater, Predicate, Equality, Reducer } from './functions.js';
import { SchedulerLike, SchedulerContinuationLike, VirtualTimeSchedulerLike } from './scheduler.js';
import { SinkLike, AbstractSource, SourceLike } from './source.js';
import { Option } from './option.js';
import { EnumerableLike } from './enumerable.js';
import { RunnableLike } from './runnable.js';
import { EnumerableLike, ToEnumerable } from './enumerable.js';
import { RunnableLike, ToRunnable } from './runnable.js';
/**
* Abstract base class for implementing the `ObserverLike` interface.
*/
declare class Observer<T> extends AbstractDisposableContainer implements SinkLike<T>, SchedulerLike {
readonly scheduler: SchedulerLike;
inContinuation: boolean;
private readonly _scheduler;
constructor(scheduler: SchedulerLike);
/** @ignore */
get now(): number;
/** @ignore */
get shouldYield(): boolean;
assertState(this: Observer<T>): void;
notify(_: T): void;
/** @ignore */
onRunStatusChanged(status: boolean): void;
/** @ignore */
requestYield(): void;
/** @ignore */
schedule(continuation: SchedulerContinuationLike, options?: {
readonly delay?: number;
}): void;
}
declare const dispatchTo: <T>(dispatcher: DispatcherLike<T>) => SideEffect1<T>;

@@ -48,2 +72,11 @@

declare const combineLatestWith: <TA, TB>(snd: ObservableLike<TB>) => ObservableOperator<TA, [TA, TB]>;
declare function zipLatest<TA, TB>(a: ObservableLike<TA>, b: ObservableLike<TB>): ObservableLike<[TA, TB]>;
declare function zipLatest<TA, TB, TC, T>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>): ObservableLike<[TA, TB, TC]>;
declare function zipLatest<TA, TB, TC, TD>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>): ObservableLike<[TA, TB, TC, TD]>;
declare function zipLatest<TA, TB, TC, TD, TE>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>): ObservableLike<[TA, TB, TC, TD, TE]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>): ObservableLike<[TA, TB, TC, TD, TE, TF]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF, TG>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>, g: ObservableLike<TG>): ObservableLike<[TA, TB, TC, TD, TE, TF, TG]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF, TG, TH>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>, g: ObservableLike<TG>, h: ObservableLike<TH>): ObservableLike<[TA, TB, TC, TD, TE, TF, TG, TH]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF, TG, TH, TI>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>, g: ObservableLike<TG>, h: ObservableLike<TH>, i: ObservableLike<TI>): ObservableLike<[TA, TB, TC, TD, TE, TF, TG, TH, TI]>;
declare const zipLatestWith: <TA, TB>(snd: ObservableLike<TB>) => ObservableOperator<TA, [TA, TB]>;

@@ -66,2 +99,3 @@ /**

declare const createObservable: <T>(onSubscribe: SideEffect1<DispatcherLike<T>>) => ObservableLike<T>;
declare const createObservableWithScheduler: <T>(f: Function1<SchedulerLike, ObservableLike<T>>) => ObservableLike<T>;

@@ -124,2 +158,3 @@ declare const createSubject: <T>(options?: {

}) => Function1<Iterable<T>, ObservableLike<T>>;
declare const fromIterableT: FromIterable<ObservableLike<unknown>>;

@@ -169,29 +204,11 @@ /**

declare function using<TResource extends DisposableLike, T>(resourceFactory: Function1<SchedulerLike, TResource>, observableFactory: Function1<TResource, ObservableLike<T>>): ObservableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, T>(resourceFactory: Function1<SchedulerLike, [TResource1, TResource2]>, observableFactory: Function2<TResource1, TResource2, ObservableLike<T>>): ObservableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, T>(resourceFactory: Function1<SchedulerLike, [
TResource1,
TResource2,
TResource3
]>, observableFactory: Function3<TResource1, TResource2, TResource3, ObservableLike<T>>): ObservableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, TResource4 extends DisposableLike, T>(resourceFactory: Function1<SchedulerLike, [
TResource1,
TResource2,
TResource3,
TResource4
]>, observableFactory: Function4<TResource1, TResource2, TResource3, TResource4, ObservableLike<T>>): ObservableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, TResource4 extends DisposableLike, TResource5 extends DisposableLike, T>(resourceFactory: Function1<SchedulerLike, [
TResource1,
TResource2,
TResource3,
TResource4,
TResource5
]>, observableFactory: Function5<TResource1, TResource2, TResource3, TResource4, TResource5, ObservableLike<T>>): ObservableLike<T>;
declare function using<TResource extends DisposableLike, T>(resourceFactory: Function1<SchedulerLike, TResource | readonly TResource[]>, observableFactory: (...resources: readonly TResource[]) => ObservableLike<T>): ObservableLike<T>;
declare const using: Using<ObservableLike<unknown>>["using"];
declare const usingT: Using<ObservableLike<unknown>>;
declare const defer: <T>(factory: Function1<ObserverLike<T>, SideEffect>, options?: {
declare const defer: <T>(factory: Factory<SideEffect1<Observer<T>>>, options?: {
readonly delay?: number;
}) => ObservableLike<T>;
declare const observe: <T>(observer: ObserverLike<T>) => SideEffect1<ObservableLike<T>>;
declare abstract class AbstractObservable<T> extends AbstractSource<T, Observer<T>> implements ObservableLike<T> {
}

@@ -210,38 +227,2 @@ /**

/**
* Returns an `ObservableLike` which catches errors produced by the source and either continues with
* the `ObservableLike` returned from the `onError` callback or swallows the error if
* void is returned.
*
* @param onError a function that takes source error and either returns an `ObservableLike`
* to continue with or void if the error should be propagated.
*/
declare const catchError: <T>(onError: Function1<unknown, void | ObservableLike<T>>) => ObservableOperator<T, T>;
/**
* Returns an `ObservableLike` that emits all items emitted by the source that
* are distinct by comparison from the previous item.
*
* @param equals Optional equality function that is used to compare
* if an item is distinct from the previous item.
*/
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T> | undefined;
}) => ObservableOperator<T, T>;
/**
* Returns an `ObservableLike` that only emits items from the
* source that satisfy the specified type predicate.
*
* @param predicate The predicate function.
*/
declare const keep: <T>(predicate: Predicate<T>) => ObservableOperator<T, T>;
declare const keepT: Keep<ObservableLike<unknown>>;
/**
* Returns an `ObservableLike` that applies the `mapper` function to each
* value emitted by the source.
*
* @param mapper The map function to apply each value. Must be a pure function.
*/
declare const map: <TA, TB>(mapper: Function1<TA, TB>) => ObservableOperator<TA, TB>;

@@ -293,3 +274,3 @@ declare const mapT: Map<ObservableLike<unknown>>;

*/
declare function onNotify<T>(onNotify: SideEffect1<T>): ObservableOperator<T, T>;
declare const onNotify: <T>(onNotify: SideEffect1<T>) => ObservableOperator<T, T>;

@@ -302,4 +283,2 @@ /**

declare const pairwise: <T>() => ObservableOperator<T, [Option<T>, T]>;
/**

@@ -316,4 +295,2 @@ * Returns a `MulticastObservableLike` backed by a single subscription to the source.

declare const reduce: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => ObservableOperator<T, TAcc>;
/**

@@ -335,2 +312,3 @@ * Returns an `ObservableLike` that applies the predicate function each time the source

declare function repeat<T>(): ObservableOperator<T, T>;
declare const repeatT: Repeat<ObservableLike<unknown>>;
/**

@@ -350,11 +328,2 @@ * Returns an `ObservableLike` that mirrors the source, re-subscribing

/**
* Returns an `ObservableLike` that applies an accumulator function over the source,
* and emits each intermediate result.
*
* @param scanner The accumulator function called on each source value.
* @param initialValue The initial accumulation value.
*/
declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => ObservableOperator<T, TAcc>;
/**
* Returns the `ObservableLike` that applies an asynchronous accumulator function

@@ -382,11 +351,2 @@ * over the source, and emits each intermediate result.

/**
* Returns an `ObservableLike` that skips the first count items emitted by the source.
*
* @param count The number of items emitted by source that should be skipped.
*/
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => ObservableOperator<T, T>;
/**
* Returns an `ObservableLike` instance that subscribes to the source on the specified `SchedulerLike`.

@@ -405,34 +365,10 @@ *

/**
* Returns an `ObservableLike` that only emits the first `count` values emitted by the source.
*
* @param count The maximum number of values to emit.
*/
declare const takeFirst: <T>(options?: {
readonly count?: number;
}) => ObservableOperator<T, T>;
declare const takeFirstT: TakeFirst<ObservableLike<unknown>>;
/**
* Returns an `ObservableLike` that only emits the last `count` items emitted by the source.
*
* @param count The maximum number of values to emit.
*/
declare const takeLast: <T>(options?: {
readonly count?: number;
}) => ObservableOperator<T, T>;
declare const takeUntil: <T>(notifier: ObservableLike<unknown>) => ObservableOperator<T, T>;
/**
* Returns an `ObservableLike` which emits values emitted by the source as long
* as each value satisfies the given predicate, and then completes as soon as
* this predicate is not satisfied.
*
* @param predicate The predicate function.
*/
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => ObservableOperator<T, T>;
/**
* Emits a value from the source, then ignores subsequent source values for a duration determined by another observable.

@@ -458,9 +394,2 @@ *

/**
* Returns an `ObservableLike` that emits an error if the source completes without emitting a value.
*
* @param factory A factory function invoked to produce the error to be thrown.
*/
declare const throwIfEmpty: <T>(factory: Factory<unknown>) => ObservableOperator<T, T>;
/** Symbol thrown when the timeout operator times out */

@@ -500,12 +429,2 @@ declare const timeoutError: symbol;

declare function zipLatest<TA, TB>(a: ObservableLike<TA>, b: ObservableLike<TB>): ObservableLike<[TA, TB]>;
declare function zipLatest<TA, TB, TC, T>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>): ObservableLike<[TA, TB, TC]>;
declare function zipLatest<TA, TB, TC, TD>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>): ObservableLike<[TA, TB, TC, TD]>;
declare function zipLatest<TA, TB, TC, TD, TE>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>): ObservableLike<[TA, TB, TC, TD, TE]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>): ObservableLike<[TA, TB, TC, TD, TE, TF]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF, TG>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>, g: ObservableLike<TG>): ObservableLike<[TA, TB, TC, TD, TE, TF, TG]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF, TG, TH>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>, g: ObservableLike<TG>, h: ObservableLike<TH>): ObservableLike<[TA, TB, TC, TD, TE, TF, TG, TH]>;
declare function zipLatest<TA, TB, TC, TD, TE, TF, TG, TH, TI>(a: ObservableLike<TA>, b: ObservableLike<TB>, c: ObservableLike<TC>, d: ObservableLike<TD>, e: ObservableLike<TE>, f: ObservableLike<TF>, g: ObservableLike<TG>, h: ObservableLike<TH>, i: ObservableLike<TI>): ObservableLike<[TA, TB, TC, TD, TE, TF, TG, TH, TI]>;
declare const zipLatestWith: <TA, TB>(snd: ObservableLike<TB>) => ObservableOperator<TA, [TA, TB]>;
/**

@@ -521,2 +440,3 @@ * Returns an `ObservableLike` which combines the source with

declare const toEnumerable: <T>() => Function1<ObservableLike<T>, EnumerableLike<T>>;
declare const toEnumerableT: ToEnumerable<ObservableLike<unknown>>;

@@ -526,2 +446,3 @@ declare const toRunnable: <T>(options?: {

}) => Function1<ObservableLike<T>, RunnableLike<T>>;
declare const toRunnableT: ToRunnable<ObservableLike<unknown>>;

@@ -537,12 +458,2 @@ /**

/**
* The underlying mechanism for receiving and transforming notifications from an
* observable source. The `ObserverLike` interface composes the `SchedulerLike` and
* `DisposableLike` interfaces into a single unified type, while adding the capability
* to receive notifications.
*
* @noInheritDoc
*/
interface ObserverLike<T> extends SinkLike<T>, SchedulerLike {
}
/**
* The source of notifications which notifies a `ObserverLike` instance.

@@ -552,11 +463,8 @@ *

*/
interface ObservableLike<T> extends ContainerLike {
interface ObservableLike<T> extends SourceLike {
readonly T: unknown;
readonly type: ObservableLike<this["T"]>;
readonly isSynchronous: boolean;
/**
* Subscribes the `ObserverLike` instance to the observable.
* @param observer The observer which should be notified by the observable source.
*/
observe(this: ObservableLike<T>, observer: ObserverLike<T>): void;
readonly liftedStateType: Observer<this["T"]>;
readonly isSynchronous?: boolean;
sink(this: ObservableLike<T>, sink: Observer<T>): void;
}

@@ -605,2 +513,60 @@ declare const type: ObservableLike<unknown>;

export { AsyncReducer, DispatcherLike, MulticastObservableLike, ObservableEffectMode, ObservableLike, ObservableOperator, ObserverLike, StreamLike, SubjectLike, ThrottleMode, __currentScheduler, __do, __memo, __observe, __using, buffer, catchError, combineLatest, combineLatestWith, concat, concatAll, concatAllT, concatT, createObservable, createSubject, defer, dispatchTo, distinctUntilChanged, exhaust, exhaustT, fromArray, fromArrayT, fromDisposable, fromEnumerable, fromIterable, fromIterator, fromIteratorT, fromPromise, generate, keep, keepT, map, mapAsync, mapT, merge, mergeAll, mergeAllT, mergeWith, never, observable, observe, onNotify, onSubscribe, pairwise, publish, reduce, repeat, retry, scan, scanAsync, share, skipFirst, subscribe, subscribeOn, switchAll, switchAllT, takeFirst, takeLast, takeUntil, takeWhile, throttle, throwIfEmpty, timeout, timeoutError, toEnumerable, toPromise, toRunnable, type, using, withLatestFrom, zip, zipLatest, zipLatestWith, zipT, zipWithLatestFrom };
declare const catchError: <T>(onError: Function1<unknown, ObservableLike<T> | void>) => ObservableOperator<T, T>;
declare const decodeWithCharset: (charset?: string) => ObservableOperator<ArrayBuffer, string>;
declare const decodeWithCharsetT: DecodeWithCharset<ObservableLike<unknown>>;
/**
* Returns an `ObservableLike` that emits all items emitted by the source that
* are distinct by comparison from the previous item.
*
* @param equals Optional equality function that is used to compare
* if an item is distinct from the previous item.
*/
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T>;
}) => ObservableOperator<T, T>;
declare const distinctUntilChangedT: DistinctUntilChanged<ObservableLike<unknown>>;
declare const everySatisfy: <T>(predicate: Predicate<T>) => ObservableOperator<T, boolean>;
declare const everySatisfyT: EverySatisfy<ObservableLike<unknown>>;
declare const keep: <T>(predicate: Predicate<T>) => ObservableOperator<T, T>;
declare const keepT: Keep<ObservableLike<unknown>>;
declare const pairwise: <T>() => ObservableOperator<T, [Option<T>, T]>;
declare const pairwiseT: Pairwise<ObservableLike<unknown>>;
declare const reduce: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => ObservableOperator<T, TAcc>;
declare const reduceT: Reduce<ObservableLike<unknown>>;
declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => ObservableOperator<T, TAcc>;
declare const scanT: Scan<ObservableLike<unknown>>;
/**
* Returns an `ObservableLike` that skips the first count items emitted by the source.
*
* @param count The number of items emitted by source that should be skipped.
*/
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => ObservableOperator<T, T>;
declare const skipFirstT: SkipFirst<ObservableLike<unknown>>;
declare const someSatisfy: <T>(predicate: Predicate<T>) => ObservableOperator<T, boolean>;
declare const someSatisfyT: SomeSatisfy<ObservableLike<unknown>>;
/**
* Returns an `ObservableLike` that only emits the last `count` items emitted by the source.
*
* @param count The maximum number of values to emit.
*/
declare const takeLast: <T>(options?: {
readonly count?: number;
}) => ObservableOperator<T, T>;
declare const takeLastT: TakeLast<ObservableLike<unknown>>;
/**
* Returns an `ObservableLike` which emits values emitted by the source as long
* as each value satisfies the given predicate, and then completes as soon as
* this predicate is not satisfied.
*
* @param predicate The predicate function.
*/
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => ObservableOperator<T, T>;
declare const takeWhileT: TakeWhile<ObservableLike<unknown>>;
declare const throwIfEmpty: <T>(factory: Factory<unknown>) => ObservableOperator<T, T>;
declare const throwIfEmptyT: ThrowIfEmpty<ObservableLike<unknown>>;
export { AbstractObservable, AsyncReducer, DispatcherLike, MulticastObservableLike, ObservableEffectMode, ObservableLike, ObservableOperator, Observer, StreamLike, SubjectLike, ThrottleMode, __currentScheduler, __do, __memo, __observe, __using, buffer, catchError, combineLatest, combineLatestWith, concat, concatAll, concatAllT, concatT, createObservable, createObservableWithScheduler, createSubject, decodeWithCharset, decodeWithCharsetT, defer, dispatchTo, distinctUntilChanged, distinctUntilChangedT, everySatisfy, everySatisfyT, exhaust, exhaustT, fromArray, fromArrayT, fromDisposable, fromEnumerable, fromIterable, fromIterableT, fromIterator, fromIteratorT, fromPromise, generate, keep, keepT, map, mapAsync, mapT, merge, mergeAll, mergeAllT, mergeWith, never, observable, onNotify, onSubscribe, pairwise, pairwiseT, publish, reduce, reduceT, repeat, repeatT, retry, scan, scanAsync, scanT, share, skipFirst, skipFirstT, someSatisfy, someSatisfyT, subscribe, subscribeOn, switchAll, switchAllT, takeFirst, takeFirstT, takeLast, takeLastT, takeUntil, takeWhile, takeWhileT, throttle, throwIfEmpty, throwIfEmptyT, timeout, timeoutError, toEnumerable, toEnumerableT, toPromise, toRunnable, toRunnableT, type, using, usingT, withLatestFrom, zip, zipLatest, zipLatestWith, zipT, zipWithLatestFrom };
{
"name": "@reactive-js/core",
"version": "0.1.0",
"version": "0.2.0",
"keywords": [

@@ -38,3 +38,3 @@ "asynchronous",

},
"dependencies": {
"peerDependencies": {
"react": "^18.1.0",

@@ -46,3 +46,3 @@ "scheduler": "^0.22.0"

},
"gitHead": "348535c19ca68e980b2fbae5da0df69a678f4dc5"
"gitHead": "7cdd95e851484f7b7ce2dec54faa812571968b63"
}
import { Function1, Predicate, Reducer, Factory } from './functions.js';
import { ReadonlyObjectMap } from './readonlyObjectMap.js';
declare type ReadonlyArrayOperator<TA, TB> = Function1<readonly TA[], readonly TB[]>;
declare const everySatisfy: <T>(predicate: Predicate<T>) => Function1<readonly T[], boolean>;
declare const fromObject: <T>() => Function1<ReadonlyObjectMap<T>, readonly [string, T][]>;
declare const fromObject: <T>() => Function1<Readonly<Record<string, T>>, readonly [string, T][]>;
declare const join: (separator?: string) => Function1<readonly string[], string>;

@@ -8,0 +7,0 @@ declare const keep: <T>(predicate: Predicate<T>) => ReadonlyArrayOperator<T, T>;

@@ -1,7 +0,11 @@

import { FromArray, FromArrayOptions, Keep, ContainerLike, Container, ContainerOf } from './container.js';
import { SideEffect1, Equality, Predicate, Function1, Updater, Factory, Reducer, Function2, Function3, Function4, Function5 } from './functions.js';
import { SinkLike } from './sink.js';
import { AbstractDisposableContainer, FromArray, FromArrayOptions, ContainerLike, Container, ContainerOf, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, Keep, Map, Pairwise, Reduce, Scan, SkipFirst, SomeSatisfy, TakeFirst, TakeLast, TakeWhile, ThrowIfEmpty, Using } from './container.js';
import { SideEffect1, Function1, Updater, Factory, Predicate, Equality, Reducer } from './functions.js';
import { Option } from './option.js';
import { DisposableLike } from './disposable.js';
import { SinkLike, SourceLike } from './source.js';
declare class Sink<T> extends AbstractDisposableContainer implements SinkLike<T> {
assertState(this: Sink<T>): void;
notify(_: T): void;
}
/**

@@ -13,11 +17,4 @@ * Creates an `RunnableLike` which emits all values from each source sequentially.

declare const createRunnable: <T>(run: SideEffect1<SinkLike<T>>) => RunnableLike<T>;
declare const createRunnable: <T>(run: SideEffect1<Sink<T>>) => RunnableLike<T>;
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T> | undefined;
}) => RunnableOperator<T, T>;
declare const everySatisfy: <T>(predicate: Predicate<T>) => Predicate<RunnableLike<T>>;
declare const noneSatisfy: <T>(predicate: Predicate<T>) => Predicate<RunnableLike<T>>;
declare const first: <T>() => Function1<RunnableLike<T>, Option<T>>;

@@ -35,24 +32,5 @@

declare type SinkOperator<TA, TB> = Function1<SinkLike<TB>, SinkLike<TA>>;
declare const lift: <TA, TB>(operator: SinkOperator<TA, TB>) => RunnableOperator<TA, TB>;
declare const keep: <T>(predicate: Predicate<T>) => RunnableOperator<T, T>;
declare const keepT: Keep<RunnableLike<unknown>>;
declare const last: <T>() => Function1<RunnableLike<T>, Option<T>>;
declare const map: <TA, TB>(mapper: Function1<TA, TB>) => RunnableOperator<TA, TB>;
/**
* Returns an `ObservableLike` that forwards notifications to the provided `onNotify` function.
*
* @param onNotify The function that is invoked when the observable source produces values.
*/
declare function onNotify<T>(onNotify: SideEffect1<T>): RunnableOperator<T, T>;
declare const pairwise: <T>() => RunnableOperator<T, [Option<T>, T]>;
declare const reduce: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => Function1<RunnableLike<T>, TAcc>;
/**
* Returns an RunnableLike that applies the predicate function each time the source

@@ -74,25 +52,2 @@ * completes to determine if the enumerable should be repeated.

declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => RunnableOperator<T, TAcc>;
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => RunnableOperator<T, T>;
declare const someSatisfy: <T>(predicate: Predicate<T>) => Predicate<RunnableLike<T>>;
declare const contains: <T>(value: T, options?: {
readonly equality?: Equality<T> | undefined;
}) => Predicate<RunnableLike<T>>;
declare const takeFirst: <T>(options?: {
readonly count?: number;
}) => RunnableOperator<T, T>;
declare const takeLast: <T>(options?: {
readonly count?: number;
}) => RunnableOperator<T, T>;
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => RunnableOperator<T, T>;
/**

@@ -104,19 +59,7 @@ * Accumulates all values emitted by `runnable` into an array.

declare function using<TResource extends DisposableLike, T>(resourceFactory: Factory<TResource>, observableFactory: Function1<TResource, RunnableLike<T>>): RunnableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, T>(resourceFactory: Factory<[TResource1, TResource2]>, observableFactory: Function2<TResource1, TResource2, RunnableLike<T>>): RunnableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, T>(resourceFactory: Factory<[TResource1, TResource2, TResource3]>, observableFactory: Function3<TResource1, TResource2, TResource3, RunnableLike<T>>): RunnableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, TResource4 extends DisposableLike, T>(resourceFactory: Factory<[TResource1, TResource2, TResource3, TResource4]>, observableFactory: Function4<TResource1, TResource2, TResource3, TResource4, RunnableLike<T>>): RunnableLike<T>;
declare function using<TResource1 extends DisposableLike, TResource2 extends DisposableLike, TResource3 extends DisposableLike, TResource4 extends DisposableLike, TResource5 extends DisposableLike, T>(resourceFactory: Factory<[
TResource1,
TResource2,
TResource3,
TResource4,
TResource5
]>, observableFactory: Function5<TResource1, TResource2, TResource3, TResource4, TResource5, RunnableLike<T>>): RunnableLike<T>;
declare function using<TResource extends DisposableLike, T>(resourceFactory: Factory<TResource | readonly TResource[]>, observableFactory: (...resources: readonly TResource[]) => RunnableLike<T>): RunnableLike<T>;
interface RunnableLike<T> extends ContainerLike {
interface RunnableLike<T> extends SourceLike {
readonly T: unknown;
readonly type: RunnableLike<this["T"]>;
run(this: RunnableLike<T>, sink: SinkLike<T>): void;
readonly liftedStateType: Sink<this["T"]>;
sink(this: RunnableLike<T>, sink: Sink<T>): void;
}

@@ -130,3 +73,50 @@ declare type RunnableOperator<TA, TB> = Function1<RunnableLike<TA>, RunnableLike<TB>>;

declare const type: RunnableLike<unknown>;
declare const catchError: <T>(onError: Function1<unknown, RunnableLike<T> | void>) => RunnableOperator<T, T>;
declare const decodeWithCharset: (charset?: string) => RunnableOperator<ArrayBuffer, string>;
declare const decodeWithCharsetT: DecodeWithCharset<RunnableLike<unknown>>;
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T>;
}) => RunnableOperator<T, T>;
declare const distinctUntilChangedT: DistinctUntilChanged<RunnableLike<unknown>>;
declare const everySatisfy: <T>(predicate: Predicate<T>) => RunnableOperator<T, boolean>;
declare const everySatisfyT: EverySatisfy<RunnableLike<unknown>>;
declare const keep: <T>(predicate: Predicate<T>) => RunnableOperator<T, T>;
declare const keepT: Keep<RunnableLike<unknown>>;
declare const map: <TA, TB>(mapper: Function1<TA, TB>) => RunnableOperator<TA, TB>;
declare const mapT: Map<RunnableLike<unknown>>;
/**
* Returns an `RunnableLike` that forwards notifications to the provided `onNotify` function.
*
* @param onNotify The function that is invoked when the observable source produces values.
*/
declare const onNotify: <T>(onNotify: SideEffect1<T>) => RunnableOperator<T, T>;
declare const pairwise: <T>() => RunnableOperator<T, [Option<T>, T]>;
declare const pairwiseT: Pairwise<RunnableLike<unknown>>;
declare const reduce: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => RunnableOperator<T, TAcc>;
declare const reduceT: Reduce<RunnableLike<unknown>>;
declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => RunnableOperator<T, TAcc>;
declare const scanT: Scan<RunnableLike<unknown>>;
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => RunnableOperator<T, T>;
declare const skipFirstT: SkipFirst<RunnableLike<unknown>>;
declare const someSatisfy: <T>(predicate: Predicate<T>) => RunnableOperator<T, boolean>;
declare const someSatisfyT: SomeSatisfy<RunnableLike<unknown>>;
declare const takeFirst: <T>(options?: {
readonly count?: number;
}) => RunnableOperator<T, T>;
declare const takeFirstT: TakeFirst<RunnableLike<unknown>>;
declare const takeLast: <T>(options?: {
readonly count?: number;
}) => RunnableOperator<T, T>;
declare const takeLastT: TakeLast<RunnableLike<unknown>>;
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => RunnableOperator<T, T>;
declare const takeWhileT: TakeWhile<RunnableLike<unknown>>;
declare const throwIfEmpty: <T>(factory: Factory<unknown>) => RunnableOperator<T, T>;
declare const throwIfEmptyT: ThrowIfEmpty<RunnableLike<unknown>>;
declare const using: Using<RunnableLike<unknown>>["using"];
declare const usingT: Using<RunnableLike<unknown>>;
export { RunnableLike, RunnableOperator, ToRunnable, concat, concatAll, contains, createRunnable, distinctUntilChanged, everySatisfy, first, forEach, fromArray, fromArrayT, generate, keep, keepT, last, lift, map, noneSatisfy, onNotify, pairwise, reduce, repeat, scan, skipFirst, someSatisfy, takeFirst, takeLast, takeWhile, toArray, toRunnable, type, using };
export { RunnableLike, RunnableOperator, Sink, ToRunnable, catchError, concat, concatAll, createRunnable, decodeWithCharset, decodeWithCharsetT, distinctUntilChanged, distinctUntilChangedT, everySatisfy, everySatisfyT, first, forEach, fromArray, fromArrayT, generate, keep, keepT, last, map, mapT, onNotify, pairwise, pairwiseT, reduce, reduceT, repeat, scan, scanT, skipFirst, skipFirstT, someSatisfy, someSatisfyT, takeFirst, takeFirstT, takeLast, takeLastT, takeWhile, takeWhileT, throwIfEmpty, throwIfEmptyT, toArray, toRunnable, type, using, usingT };

@@ -6,9 +6,12 @@ 'use strict';

var functions = require('./functions.js');
var option = require('./option.js');
var source = require('./source.js');
var container = require('./container.js');
var disposable = require('./disposable.js');
var container = require('./container.js');
var env = require('./env.js');
var option = require('./option.js');
var sink = require('./sink.js');
class RunnableImpl extends container.AbstractContainer {
class AbstractRunnable extends source.AbstractSource {
}
class RunnableImpl extends AbstractRunnable {
constructor(_run) {

@@ -18,3 +21,3 @@ super();

}
run(sink) {
sink(sink) {
try {

@@ -30,3 +33,19 @@ this._run(sink);

class LiftedRunnable extends container.AbstractContainer {
const fromArray = (options = {}) => values => {
var _a, _b;
const valuesLength = values.length;
const startIndex = Math.min((_a = options.startIndex) !== null && _a !== void 0 ? _a : 0, valuesLength);
const endIndex = Math.max(Math.min((_b = options.endIndex) !== null && _b !== void 0 ? _b : values.length, valuesLength), 0);
const run = (sink) => {
for (let index = startIndex; index < endIndex && !sink.isDisposed; index++) {
sink.notify(values[index]);
}
};
return createRunnable(run);
};
const fromArrayT = {
fromArray,
};
class LiftedRunnable extends AbstractRunnable {
constructor(src, operators) {

@@ -37,5 +56,5 @@ super();

}
run(sink) {
sink(sink) {
const liftedSink = functions.pipe(sink, ...this.operators);
this.src.run(liftedSink);
this.src.sink(liftedSink);
liftedSink.dispose();

@@ -51,35 +70,23 @@ }

};
const liftT = {
variance: "contravariant",
lift,
};
const assertStateProduction = functions.ignore;
const assertStateDev = function () {
if (this.isDisposed) {
functions.raise("Sink is disposed");
}
};
const assertState = env.__DEV__ ? assertStateDev : assertStateProduction;
class AbstractSink extends disposable.AbstractDisposable {
class Sink extends container.AbstractDisposableContainer {
assertState() { }
notify(_) { }
}
AbstractSink.prototype.assertState = assertState;
class AbstractDelegatingSink extends AbstractSink {
constructor(delegate) {
super();
this.delegate = delegate;
disposable.addDisposable(delegate, this);
}
if (env.__DEV__) {
Sink.prototype.assertState = function () {
if (this.isDisposed) {
functions.raise("Sink is disposed");
}
};
}
class AbstractAutoDisposingDelegatingSink extends AbstractSink {
class DelegatingSink extends Sink {
constructor(delegate) {
super();
this.delegate = delegate;
disposable.bindDisposables(this, delegate);
}
}
class DelegatingSink extends AbstractSink {
constructor(delegate) {
super();
this.delegate = delegate;
disposable.addDisposable(delegate, this);
}
notify(next) {

@@ -89,3 +96,7 @@ this.delegate.notify(next);

}
const createDelegatingSink = (delegate) => new DelegatingSink(delegate);
const createDelegatingSink = (delegate) => {
const sink = new DelegatingSink(delegate);
disposable.addDisposable(delegate, sink);
return sink;
};

@@ -98,3 +109,3 @@ function concat(...runnables) {

disposable.addDisposableDisposeParentOnChildError(sink, concatSink);
runnables[i].run(concatSink);
runnables[i].sink(concatSink);
concatSink.dispose();

@@ -104,31 +115,24 @@ }

}
class FlattenSink extends AbstractDelegatingSink {
class FlattenSink extends Sink {
constructor(delegate) {
super();
this.delegate = delegate;
}
notify(next) {
const concatSink = createDelegatingSink(this.delegate);
disposable.addDisposableDisposeParentOnChildError(this.delegate, concatSink);
next.run(concatSink);
next.sink(concatSink);
concatSink.dispose();
}
}
const _concatAll = lift(s => new FlattenSink(s));
const _concatAll = lift(delegate => {
const sink = new FlattenSink(delegate);
disposable.addDisposable(delegate, sink);
return sink;
});
const concatAll = () => _concatAll;
class DistinctUntilChangedSink extends AbstractAutoDisposingDelegatingSink {
constructor(delegate, equality) {
super(delegate);
this.equality = equality;
this.prev = option.none;
this.hasValue = false;
}
}
DistinctUntilChangedSink.prototype.notify = sink.notifyDistinctUntilChanged;
const distinctUntilChanged = (options = {}) => {
const { equality = functions.strictEquality } = options;
const operator = (sink) => new DistinctUntilChangedSink(sink, equality);
return lift(operator);
};
const run = (f) => (runnable) => {
const sink = f();
runnable.run(sink);
runnable.sink(sink);
sink.dispose();

@@ -142,22 +146,3 @@ const { error } = sink;

class EverySatisfySink extends AbstractSink {
constructor(predicate) {
super();
this.predicate = predicate;
this.result = true;
}
notify(next) {
if (!this.predicate(next)) {
this.result = false;
this.dispose();
}
}
}
const everySatisfy = (predicate) => {
const createSink = () => new EverySatisfySink(predicate);
return run(createSink);
};
const noneSatisfy = (predicate) => everySatisfy(functions.compose(predicate, functions.negate));
class FirstSink extends AbstractSink {
class FirstSink extends Sink {
constructor() {

@@ -177,3 +162,3 @@ super(...arguments);

class ForEachSink extends AbstractSink {
class ForEachSink extends Sink {
constructor(notify) {

@@ -190,18 +175,2 @@ super();

const fromArray = (options = {}) => values => {
var _a, _b;
const valuesLength = values.length;
const startIndex = Math.min((_a = options.startIndex) !== null && _a !== void 0 ? _a : 0, valuesLength);
const endIndex = Math.max(Math.min((_b = options.endIndex) !== null && _b !== void 0 ? _b : values.length, valuesLength), 0);
const run = (sink) => {
for (let index = startIndex; index < endIndex && !sink.isDisposed; index++) {
sink.notify(values[index]);
}
};
return createRunnable(run);
};
const fromArrayT = {
fromArray,
};
const generate = (generator, initialValue) => {

@@ -218,18 +187,3 @@ const run = (sink) => {

class KeepSink extends AbstractAutoDisposingDelegatingSink {
constructor(delegate, predicate) {
super(delegate);
this.predicate = predicate;
}
}
KeepSink.prototype.notify = sink.notifyKeep;
const keep = (predicate) => {
const operator = (sink) => new KeepSink(sink, predicate);
return lift(operator);
};
const keepT = {
keep,
};
class LastSink extends AbstractSink {
class LastSink extends Sink {
constructor() {

@@ -248,59 +202,2 @@ super(...arguments);

class MapSink extends AbstractAutoDisposingDelegatingSink {
constructor(delegate, mapper) {
super(delegate);
this.mapper = mapper;
}
}
MapSink.prototype.notify = sink.notifyMap;
const map = (mapper) => {
const operator = (sink) => new MapSink(sink, mapper);
return lift(operator);
};
class OnNotifySink extends AbstractAutoDisposingDelegatingSink {
constructor(delegate, onNotify) {
super(delegate);
this.onNotify = onNotify;
}
}
OnNotifySink.prototype.notify = sink.notifyOnNotify;
/**
* Returns an `ObservableLike` that forwards notifications to the provided `onNotify` function.
*
* @param onNotify The function that is invoked when the observable source produces values.
*/
function onNotify(onNotify) {
const operator = (observer) => new OnNotifySink(observer, onNotify);
return lift(operator);
}
class PairwiseObserver extends AbstractAutoDisposingDelegatingSink {
constructor() {
super(...arguments);
this.hasPrev = false;
}
}
PairwiseObserver.prototype.notify = sink.notifyPairwise;
const pairwise = () => {
const operator = (observer) => new PairwiseObserver(observer);
return lift(operator);
};
class ReducerSink extends AbstractSink {
constructor(acc, reducer) {
super();
this.acc = acc;
this.reducer = reducer;
}
get result() {
return this.acc;
}
}
ReducerSink.prototype.notify = sink.notifyReduce;
const reduce = (reducer, initialValue) => {
const createSink = () => new ReducerSink(initialValue(), reducer);
return run(createSink);
};
function repeat(predicate) {

@@ -316,153 +213,217 @@ const shouldRepeat = option.isNone(predicate)

const delegateSink = createDelegatingSink(sink);
runnable.run(delegateSink);
runnable.sink(delegateSink);
delegateSink.dispose();
count++;
} while (!sink.isDisposed && shouldRepeat(count));
sink.dispose();
});
}
class ScanSink extends AbstractAutoDisposingDelegatingSink {
class ToArraySink extends Sink {
constructor() {
super(...arguments);
this.result = [];
}
notify(next) {
this.result.push(next);
}
}
const createSink = () => new ToArraySink();
/**
* Accumulates all values emitted by `runnable` into an array.
*
*/
const toArray = () => run(createSink);
const toRunnable = () => functions.identity;
const type = undefined;
const catchError = source.createCatchErrorOperator(liftT, class CatchErrorSink extends Sink {
constructor(delegate) {
super();
this.delegate = delegate;
}
});
const decodeWithCharset = source.createDecodeWithCharsetOperator({ ...liftT, ...fromArrayT }, class DecodeWithCharsetSink extends Sink {
constructor(delegate, textDecoder) {
super();
this.delegate = delegate;
this.textDecoder = textDecoder;
}
});
const decodeWithCharsetT = {
decodeWithCharset,
};
const distinctUntilChanged = source.createDistinctUntilChangedOperator(liftT, class DistinctUntilChangedSink extends Sink {
constructor(delegate, equality) {
super();
this.delegate = delegate;
this.equality = equality;
this.prev = option.none;
this.hasValue = false;
}
});
const distinctUntilChangedT = {
distinctUntilChanged,
};
const everySatisfy = source.createEverySatisfyOperator({ ...fromArrayT, ...liftT }, class EverySatisfySink extends Sink {
constructor(delegate, predicate) {
super();
this.delegate = delegate;
this.predicate = predicate;
}
});
const everySatisfyT = {
everySatisfy,
};
const keep = source.createKeepOperator(liftT, class KeepSink extends Sink {
constructor(delegate, predicate) {
super();
this.delegate = delegate;
this.predicate = predicate;
}
});
const keepT = {
keep,
};
const map = source.createMapOperator(liftT, class MapSink extends Sink {
constructor(delegate, mapper) {
super();
this.delegate = delegate;
this.mapper = mapper;
}
});
const mapT = {
map,
};
/**
* Returns an `RunnableLike` that forwards notifications to the provided `onNotify` function.
*
* @param onNotify The function that is invoked when the observable source produces values.
*/
const onNotify = source.createOnNotifyOperator(liftT, class OnNotifySink extends Sink {
constructor(delegate, onNotify) {
super();
this.delegate = delegate;
this.onNotify = onNotify;
}
});
const pairwise = source.createPairwiseOperator(liftT, class PairwiseSink extends Sink {
constructor(delegate) {
super();
this.delegate = delegate;
this.hasPrev = false;
}
});
const pairwiseT = {
pairwise,
};
const reduce = source.createReduceOperator({ ...fromArrayT, ...liftT }, class ReducerSink extends Sink {
constructor(delegate, reducer, acc) {
super(delegate);
super();
this.delegate = delegate;
this.reducer = reducer;
this.acc = acc;
}
}
ScanSink.prototype.notify = sink.notifyScan;
const scan = (reducer, initialValue) => {
const operator = (sink) => new ScanSink(sink, reducer, initialValue());
return lift(operator);
});
const reduceT = {
reduce,
};
class SkipFirstSink extends AbstractAutoDisposingDelegatingSink {
const scan = source.createScanOperator(liftT, class ScanSink extends Sink {
constructor(delegate, reducer, acc) {
super();
this.delegate = delegate;
this.reducer = reducer;
this.acc = acc;
}
});
const scanT = {
scan,
};
const skipFirst = source.createSkipFirstOperator(liftT, class SkipFirstSink extends Sink {
constructor(delegate, skipCount) {
super(delegate);
super();
this.delegate = delegate;
this.skipCount = skipCount;
this.count = 0;
}
}
SkipFirstSink.prototype.notify = sink.notifySkipFirst;
const skipFirst = (options = {}) => {
const { count = 1 } = options;
const operator = (sink) => new SkipFirstSink(sink, count);
return runnable => (count > 0 ? functions.pipe(runnable, lift(operator)) : runnable);
});
const skipFirstT = {
skipFirst,
};
class SomeSatisfySink extends AbstractSink {
constructor(predicate) {
const someSatisfy = source.createSomeSatisfyOperator({ ...fromArrayT, ...liftT }, class SomeSatisfySink extends Sink {
constructor(delegate, predicate) {
super();
this.delegate = delegate;
this.predicate = predicate;
this.result = false;
}
notify(next) {
if (this.predicate(next)) {
this.result = true;
this.dispose();
}
}
}
const someSatisfy = (predicate) => {
const createSink = () => new SomeSatisfySink(predicate);
return run(createSink);
});
const someSatisfyT = {
someSatisfy,
};
const contains = (value, options = {}) => {
const { equality = functions.strictEquality } = options;
return someSatisfy(functions.isEqualTo(value, equality));
};
class TakeFirstSink extends AbstractAutoDisposingDelegatingSink {
const takeFirst = source.createTakeFirstOperator({ ...fromArrayT, ...liftT }, class TakeFirstSink extends Sink {
constructor(delegate, maxCount) {
super(delegate);
super();
this.delegate = delegate;
this.maxCount = maxCount;
this.count = 0;
}
}
TakeFirstSink.prototype.notify = sink.notifyTakeFirst;
const takeFirst = (options = {}) => {
const { count = 1 } = options;
const operator = (sink) => new TakeFirstSink(sink, count);
return observable => count > 0 ? functions.pipe(observable, lift(operator)) : container.empty(fromArrayT);
});
const takeFirstT = {
takeFirst,
};
function onDispose(error) {
if (option.isSome(error)) {
this.last.length = 0;
functions.pipe(this.delegate, disposable.dispose(error));
}
else {
fromArray()(this.last).run(this.delegate);
}
}
class TakeLastSink extends AbstractDelegatingSink {
const takeLast = source.createTakeLastOperator({ ...fromArrayT, ...liftT }, class TakeLastSink extends Sink {
constructor(delegate, maxCount) {
super(delegate);
super();
this.delegate = delegate;
this.maxCount = maxCount;
this.last = [];
disposable.addTeardown(this, onDispose);
}
}
TakeLastSink.prototype.notify = sink.notifyTakeLast;
const takeLast = (options = {}) => {
const { count = 1 } = options;
const operator = (sink) => new TakeLastSink(sink, count);
return runnable => count > 0 ? functions.pipe(runnable, lift(operator)) : container.empty(fromArrayT);
});
const takeLastT = {
takeLast,
};
class TakeWhileSink extends AbstractAutoDisposingDelegatingSink {
const takeWhile = source.createTakeWhileOperator(liftT, class TakeWhileSink extends Sink {
constructor(delegate, predicate, inclusive) {
super(delegate);
super();
this.delegate = delegate;
this.predicate = predicate;
this.inclusive = inclusive;
}
}
TakeWhileSink.prototype.notify = sink.notifyTakeWhile;
const takeWhile = (predicate, options = {}) => {
const { inclusive = false } = options;
const operator = (sink) => new TakeWhileSink(sink, predicate, inclusive);
return lift(operator);
});
const takeWhileT = {
takeWhile,
};
class ToArraySink extends AbstractSink {
constructor() {
super(...arguments);
this.result = [];
const throwIfEmpty = source.createThrowIfEmptyOperator(liftT, class ThrowIfEmptySink extends Sink {
constructor(delegate) {
super();
this.delegate = delegate;
this.isEmpty = true;
}
notify(next) {
this.result.push(next);
});
const throwIfEmptyT = {
throwIfEmpty,
};
const using = source.createUsing(class UsingRunnable extends AbstractRunnable {
constructor(resourceFactory, sourceFactory) {
super();
this.resourceFactory = resourceFactory;
this.sourceFactory = sourceFactory;
this.isSynchronous = false;
}
}
const createSink = () => new ToArraySink();
/**
* Accumulates all values emitted by `runnable` into an array.
*
*/
const toArray = () => run(createSink);
sink(_) { }
});
const usingT = {
using,
};
/**
* Creates an `RunnableLike` that uses one or more resources which
* will be disposed when the RunnableLike disposes it's only subscription.
*/
function using(resourceFactory, runnableFactory) {
const run = (sink) => {
const resources = resourceFactory();
const resourcesArray = Array.isArray(resources) ? resources : [resources];
const runnable = runnableFactory(...resourcesArray);
for (const r of resourcesArray) {
disposable.addDisposableDisposeParentOnChildError(sink, r);
}
runnable.run(sink);
};
return createRunnable(run);
}
const toRunnable = () => functions.identity;
const type = undefined;
exports.Sink = Sink;
exports.catchError = catchError;
exports.concat = concat;
exports.concatAll = concatAll;
exports.contains = contains;
exports.createRunnable = createRunnable;
exports.decodeWithCharset = decodeWithCharset;
exports.decodeWithCharsetT = decodeWithCharsetT;
exports.distinctUntilChanged = distinctUntilChanged;
exports.distinctUntilChangedT = distinctUntilChangedT;
exports.everySatisfy = everySatisfy;
exports.everySatisfyT = everySatisfyT;
exports.first = first;

@@ -476,15 +437,24 @@ exports.forEach = forEach;

exports.last = last;
exports.lift = lift;
exports.map = map;
exports.noneSatisfy = noneSatisfy;
exports.mapT = mapT;
exports.onNotify = onNotify;
exports.pairwise = pairwise;
exports.pairwiseT = pairwiseT;
exports.reduce = reduce;
exports.reduceT = reduceT;
exports.repeat = repeat;
exports.scan = scan;
exports.scanT = scanT;
exports.skipFirst = skipFirst;
exports.skipFirstT = skipFirstT;
exports.someSatisfy = someSatisfy;
exports.someSatisfyT = someSatisfyT;
exports.takeFirst = takeFirst;
exports.takeFirstT = takeFirstT;
exports.takeLast = takeLast;
exports.takeLastT = takeLastT;
exports.takeWhile = takeWhile;
exports.takeWhileT = takeWhileT;
exports.throwIfEmpty = throwIfEmpty;
exports.throwIfEmptyT = throwIfEmptyT;
exports.toArray = toArray;

@@ -494,1 +464,2 @@ exports.toRunnable = toRunnable;

exports.using = using;
exports.usingT = usingT;

@@ -109,3 +109,2 @@ 'use strict';

this.listeners = option.none;
disposable.addTeardown(this, clearListeners);
}

@@ -129,3 +128,3 @@ addListener(_ev, listener) {

if (!this.isDisposed) {
const listeners = this.listeners;
const { listeners } = this;
let error = option.none;

@@ -175,2 +174,3 @@ let yieldError = option.none;

const continuation = new SchedulerContinuationImpl(scheduler, f);
disposable.addTeardown(continuation, clearListeners);
scheduler.schedule(continuation, options);

@@ -268,4 +268,2 @@ return continuation;

this.yieldRequested = false;
disposable.addTeardown(this, clearQueues);
disposable.addDisposable(host, this);
}

@@ -276,3 +274,3 @@ get now() {

get shouldYield() {
const current = this.current;
const { current } = this;
const next = peek(this);

@@ -319,3 +317,3 @@ const nextTaskIsHigherPriority = option.isSome(current) &&

if (!continuation.isDisposed) {
const now = this.now;
const { now } = this;
const dueTime = Math.max(now + delay, now);

@@ -344,2 +342,8 @@ const task = this.inContinuation &&

}
const createPriorityScheduler = (hostScheduler) => {
const scheduler = new PriorityScheduler(hostScheduler);
disposable.addTeardown(scheduler, clearQueues);
disposable.addDisposable(hostScheduler, scheduler);
return scheduler;
};
/**

@@ -352,5 +356,7 @@ * Creates a new priority scheduler which schedules work using the provided

*/
const toPriorityScheduler = (hostScheduler) => new PriorityScheduler(hostScheduler);
const toPriorityScheduler = (hostScheduler) => {
return createPriorityScheduler(hostScheduler);
};
const toPausableScheduler = (hostScheduler) => {
const scheduler = new PriorityScheduler(hostScheduler);
const scheduler = createPriorityScheduler(hostScheduler);
scheduler.pause();

@@ -365,3 +371,2 @@ return scheduler;

this.priority = priority;
disposable.addDisposable(priorityScheduler, this);
}

@@ -395,3 +400,7 @@ get inContinuation() {

*/
const toSchedulerWithPriority = (priority) => priorityScheduler => new SchedulerWithPriorityImpl(priorityScheduler, priority);
const toSchedulerWithPriority = (priority) => priorityScheduler => {
const scheduler = new SchedulerWithPriorityImpl(priorityScheduler, priority);
disposable.addDisposable(priorityScheduler, scheduler);
return scheduler;
};

@@ -461,11 +470,2 @@ const supportsPerformanceNow = typeof performance === "object" && typeof performance.now === "function";

this.yieldRequested = false;
const supportsMessageChannel = typeof MessageChannel === "function";
if (supportsMessageChannel) {
const messageChannel = new MessageChannel();
this.messageChannel = messageChannel;
disposable.addTeardown(this, () => {
messageChannel.port1.close();
messageChannel.port2.close();
});
}
}

@@ -502,3 +502,13 @@ get now() {

const { yieldInterval = 5 } = options;
return new HostScheduler(yieldInterval);
const hostScheduler = new HostScheduler(yieldInterval);
const supportsMessageChannel = typeof MessageChannel === "function";
if (supportsMessageChannel) {
const messageChannel = new MessageChannel();
hostScheduler.messageChannel = messageChannel;
disposable.addTeardown(hostScheduler, () => {
messageChannel.port1.close();
messageChannel.port2.close();
});
}
return hostScheduler;
};

@@ -505,0 +515,0 @@

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

import { ContainerLike } from './container.js';
import { ContainerLike, ConcatAll, FromArray, Concat, DistinctUntilChanged, Keep, Map, Generate, TakeFirst, Repeat, Scan, SkipFirst, TakeLast, TakeWhile } from './container.js';
import { Factory, Function1, Equality, Predicate, Updater, Reducer } from './functions.js';
import { RunnableLike } from './runnable.js';
import { RunnableLike, ToRunnable } from './runnable.js';

@@ -19,2 +19,3 @@ interface SequenceResultNotify<T> {

declare const concatAll: <T>() => SequenceOperator<Sequence<T>, T>;
declare const concatAllT: ConcatAll<Sequence<unknown>>;
declare const fromArray: <T>(options?: {

@@ -24,9 +25,15 @@ readonly startIndex?: number;

}) => Function1<readonly T[], Sequence<T>>;
declare const fromArrayT: FromArray<Sequence<unknown>>;
declare function concat<T>(fst: Sequence<T>, snd: Sequence<T>, ...tail: readonly Sequence<T>[]): Sequence<T>;
declare const concatT: Concat<Sequence<unknown>>;
declare const distinctUntilChanged: <T>(options?: {
readonly equality?: Equality<T> | undefined;
}) => SequenceOperator<T, T>;
declare const distinctUntilChangedT: DistinctUntilChanged<Sequence<unknown>>;
declare const keep: <T>(predicate: Predicate<T>) => SequenceOperator<T, T>;
declare const keepT: Keep<Sequence<unknown>>;
declare const map: <TA, TB>(mapper: Function1<TA, TB>) => SequenceOperator<TA, TB>;
declare const mapT: Map<Sequence<unknown>>;
declare const generate: <T>(generator: Updater<T>, initialValue: Factory<T>) => Sequence<T>;
declare const generateT: Generate<Sequence<unknown>>;
declare const seek: <T>(count: number) => SequenceOperator<T, T>;

@@ -36,17 +43,24 @@ declare const takeFirst: <T>(options?: {

}) => SequenceOperator<T, T>;
declare const takeFirstT: TakeFirst<Sequence<unknown>>;
declare function repeat<T>(predicate: Predicate<number>): SequenceOperator<T, T>;
declare function repeat<T>(count: number): SequenceOperator<T, T>;
declare function repeat<T>(): SequenceOperator<T, T>;
declare const repeatT: Repeat<Sequence<unknown>>;
declare const scan: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>) => SequenceOperator<T, TAcc>;
declare const scanT: Scan<Sequence<unknown>>;
declare const skipFirst: <T>(options?: {
readonly count?: number;
}) => SequenceOperator<T, T>;
declare const skipFirstT: SkipFirst<Sequence<unknown>>;
declare const takeLast: <T>(options?: {
readonly count?: number;
}) => SequenceOperator<T, T>;
declare const takeLastT: TakeLast<Sequence<unknown>>;
declare const takeWhile: <T>(predicate: Predicate<T>, options?: {
readonly inclusive?: boolean;
}) => SequenceOperator<T, T>;
declare const takeWhileT: TakeWhile<Sequence<unknown>>;
declare const toRunnable: <T>() => Function1<Sequence<T>, RunnableLike<T>>;
declare const toRunnableT: ToRunnable<Sequence<unknown>>;
export { Sequence, SequenceLike, SequenceOperator, SequenceResult, SequenceResultNotify, concat, concatAll, distinctUntilChanged, fromArray, generate, keep, map, repeat, scan, seek, sequenceResultDone, skipFirst, takeFirst, takeLast, takeWhile, toRunnable, type };
export { Sequence, SequenceLike, SequenceOperator, SequenceResult, SequenceResultNotify, concat, concatAll, concatAllT, concatT, distinctUntilChanged, distinctUntilChangedT, fromArray, fromArrayT, generate, generateT, keep, keepT, map, mapT, repeat, repeatT, scan, scanT, seek, sequenceResultDone, skipFirst, skipFirstT, takeFirst, takeFirstT, takeLast, takeLastT, takeWhile, takeWhileT, toRunnable, toRunnableT, type };

@@ -37,2 +37,5 @@ 'use strict';

};
const concatAllT = {
concatAll,
};
const _fromArray = (arr, index, endIndex) => index < endIndex && index >= 0

@@ -48,5 +51,11 @@ ? notify(arr[index], () => _fromArray(arr, index + 1, endIndex))

};
const fromArrayT = {
fromArray,
};
function concat(...sequences) {
return functions.pipe(sequences, fromArray(), concatAll());
}
const concatT = {
concat,
};
const _distinctUntilChanged = (equality, prevValue, next) => castToSequence(() => {

@@ -75,2 +84,5 @@ let retval = next();

});
const distinctUntilChangedT = {
distinctUntilChanged,
};
const _keep = (predicate, seq) => castToSequence(() => {

@@ -93,2 +105,5 @@ let result = seq();

const keep = (predicate) => seq => _keep(predicate, seq);
const keepT = {
keep,
};
const _map = (mapper, seq) => castToSequence(() => {

@@ -101,2 +116,5 @@ const result = seq();

const map = (mapper) => seq => _map(mapper, seq);
const mapT = {
map,
};
const _generate = (generator, acc) => castToSequence(() => notify(acc, _generate(generator, generator(acc))));

@@ -107,2 +125,5 @@ const generate = (generator, initialValue) => castToSequence(() => {

});
const generateT = {
generate,
};
const seek = (count) => seq => {

@@ -138,2 +159,5 @@ if (count <= 0) {

};
const takeFirstT = {
takeFirst,
};
const _repeat = (predicate, count, src, seq) => castToSequence(() => {

@@ -159,2 +183,5 @@ const result = seq();

}
const repeatT = {
repeat,
};
const _scan = (reducer, acc, seq) => castToSequence(() => {

@@ -171,2 +198,5 @@ const result = seq();

const scan = (reducer, initialValue) => seq => castToSequence(() => _scan(reducer, initialValue(), seq)());
const scanT = {
scan,
};
const skipFirst = (options = {}) => seq => castToSequence(() => {

@@ -176,2 +206,5 @@ const { count = 1 } = options;

});
const skipFirstT = {
skipFirst,
};
const _takeLast = (maxCount, seq) => castToSequence(() => {

@@ -198,2 +231,5 @@ const last = [];

};
const takeLastT = {
takeLast,
};
const _takeWhile = (predicate, inclusive, seq) => castToSequence(() => {

@@ -211,2 +247,5 @@ const result = seq();

};
const takeWhileT = {
takeWhile,
};
const toRunnable = () => seq => runnable.createRunnable(sink => {

@@ -219,19 +258,36 @@ let result = seq();

});
const toRunnableT = {
toRunnable,
};
exports.concat = concat;
exports.concatAll = concatAll;
exports.concatAllT = concatAllT;
exports.concatT = concatT;
exports.distinctUntilChanged = distinctUntilChanged;
exports.distinctUntilChangedT = distinctUntilChangedT;
exports.fromArray = fromArray;
exports.fromArrayT = fromArrayT;
exports.generate = generate;
exports.generateT = generateT;
exports.keep = keep;
exports.keepT = keepT;
exports.map = map;
exports.mapT = mapT;
exports.repeat = repeat;
exports.repeatT = repeatT;
exports.scan = scan;
exports.scanT = scanT;
exports.seek = seek;
exports.sequenceResultDone = sequenceResultDone;
exports.skipFirst = skipFirst;
exports.skipFirstT = skipFirstT;
exports.takeFirst = takeFirst;
exports.takeFirstT = takeFirstT;
exports.takeLast = takeLast;
exports.takeLastT = takeLastT;
exports.takeWhile = takeWhile;
exports.takeWhileT = takeWhileT;
exports.toRunnable = toRunnable;
exports.toRunnableT = toRunnableT;
exports.type = type;

@@ -61,15 +61,10 @@ import { Reducer, Factory, Equality, Updater, Function1, Function2 } from './functions.js';

scheduler?: SchedulerLike | undefined;
}) => Function1<ObservableLike<T>, StreamableLike<FlowMode, T>>;
}) => Function1<ObservableLike<T>, FlowableLike<T>>;
declare const sink: <TReq, T>(src: StreamableLike<TReq, T>, dest: StreamableLike<T, TReq>) => ObservableLike<void>;
declare type IOEvent<T> = NotifyEvent<T> | DoneEvent;
declare const decodeWithCharset: (charset?: string, options?: TextDecoderOptions) => StreamableOperator<FlowMode, NotifyEvent<ArrayBuffer> | DoneEvent, FlowMode, NotifyEvent<string> | DoneEvent>;
declare const encodeUtf8: StreamableOperator<FlowMode, IOEvent<string>, FlowMode, IOEvent<Uint8Array>>;
declare const mapIOEventStream: <TA, TB>(mapper: Function1<TA, TB>) => Function1<StreamableLike<FlowMode, IOEvent<TA>>, StreamableLike<FlowMode, IOEvent<TB>>>;
declare const flowIOEvents: <T>() => Function1<ObservableLike<T>, StreamableLike<FlowMode, IOEvent<T>>>;
/** @experimental */
declare const createIOSinkAccumulator: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>, options?: {
declare const createFlowableSinkAccumulator: <T, TAcc>(reducer: Reducer<T, TAcc>, initialValue: Factory<TAcc>, options?: {
readonly replay?: number;
}) => IOSinkAccumulatorLike<T, TAcc>;
}) => FlowableSinkLike<T> & MulticastObservableLike<TAcc>;

@@ -85,3 +80,3 @@ /**

readonly endIndex?: number;
}) => Function1<readonly T[], StreamableLike<void, T>>;
}) => Function1<readonly T[], AsyncEnumerableLike<T>>;

@@ -93,3 +88,3 @@ /**

*/
declare const fromEnumerable: <T>() => Function1<EnumerableLike<T>, StreamableLike<void, T>>;
declare const fromEnumerable: <T>() => Function1<EnumerableLike<T>, AsyncEnumerableLike<T>>;

@@ -101,3 +96,3 @@ /**

*/
declare const fromIterable: <T>() => Function1<Iterable<T>, StreamableLike<void, T>>;
declare const fromIterable: <T>() => Function1<Iterable<T>, AsyncEnumerableLike<T>>;

@@ -113,11 +108,9 @@ /**

readonly delay?: number;
}) => StreamableLike<void, T>;
}) => AsyncEnumerableLike<T>;
declare const consume: <T, TAcc>(consumer: Function2<TAcc, T, NotifyEvent<TAcc> | DoneEventWithData<TAcc>>, initial: Factory<TAcc>) => Function1<StreamableLike<void, T>, ObservableLike<TAcc>>;
declare const consumeAsync: <T, TAcc>(consumer: Function2<TAcc, T, ObservableLike<NotifyEvent<TAcc> | DoneEventWithData<TAcc>>>, initial: Factory<TAcc>) => Function1<StreamableLike<void, T>, ObservableLike<TAcc>>;
declare const consumeContinue: <T>(data: T) => ConsumeContinue<T>;
declare const consumeDone: <T>(data: T) => ConsumeDone<T>;
declare const consume: <T, TAcc>(consumer: Function2<TAcc, T, ConsumeContinue<TAcc> | ConsumeDone<TAcc>>, initial: Factory<TAcc>) => Function1<AsyncEnumerableLike<T>, ObservableLike<TAcc>>;
declare const consumeAsync: <T, TAcc>(consumer: Function2<TAcc, T, ObservableLike<ConsumeContinue<TAcc> | ConsumeDone<TAcc>>>, initial: Factory<TAcc>) => Function1<AsyncEnumerableLike<T>, ObservableLike<TAcc>>;
declare const notifyEvent: <T>(data: T) => NotifyEvent<T>;
declare const doneEventWithData: <T>(data: T) => DoneEventWithData<T>;
declare const doneEvent: DoneEvent;
interface StreamableLike<TReq, T> {

@@ -128,22 +121,19 @@ stream(this: StreamableLike<TReq, T>, scheduler: SchedulerLike, options?: {

}
interface AsyncEnumerableLike<T> extends StreamableLike<void, T> {
}
declare type StreamableOperator<TSrcReq, TSrc, TReq, T> = Function1<StreamableLike<TSrcReq, TSrc>, StreamableLike<TReq, T>>;
/**
* @experimental
* @noInheritDoc
* */
interface IOSinkAccumulatorLike<T, TAcc> extends StreamableLike<NotifyEvent<T> | DoneEvent, FlowMode>, MulticastObservableLike<TAcc> {
declare type FlowMode = "resume" | "pause";
interface FlowableLike<T> extends StreamableLike<FlowMode, T> {
}
declare type FlowMode = "resume" | "pause";
declare type NotifyEvent<T> = {
readonly type: "notify";
interface FlowableSinkLike<T> extends StreamableLike<T, FlowMode> {
}
declare type ConsumeContinue<T> = {
readonly type: "continue";
readonly data: T;
};
declare type DoneEvent = {
declare type ConsumeDone<T> = {
readonly type: "done";
};
declare type DoneEventWithData<T> = {
readonly type: "done";
readonly data: T;
};
export { DoneEvent, DoneEventWithData, FlowMode, IOSinkAccumulatorLike, NotifyEvent, StreamableLike, StreamableOperator, __stream, consume, consumeAsync, createActionReducer, createIOSinkAccumulator, createStateStore, createStreamable, decodeWithCharset, doneEvent, doneEventWithData, empty, encodeUtf8, flow, flowIOEvents, fromArray, fromEnumerable, fromIterable, generate, identity, lift, mapIOEventStream, mapReq, notifyEvent, sink, stream, toStateStore };
export { AsyncEnumerableLike, ConsumeContinue, ConsumeDone, FlowMode, FlowableLike, FlowableSinkLike, StreamableLike, StreamableOperator, __stream, consume, consumeAsync, consumeContinue, consumeDone, createActionReducer, createFlowableSinkAccumulator, createStateStore, createStreamable, empty, flow, fromArray, fromEnumerable, fromIterable, generate, identity, lift, mapReq, sink, stream, toStateStore };

@@ -10,22 +10,13 @@ 'use strict';

var option = require('./option.js');
var source = require('./source.js');
var scheduler = require('./scheduler.js');
var enumerable = require('./enumerable.js');
class StreamImpl extends disposable.AbstractDisposable {
constructor(op, scheduler, options) {
class StreamImpl extends source.AbstractDisposableSource {
constructor(dispatcher, observable) {
super();
this.dispatcher = dispatcher;
this.observable = observable;
this.isSynchronous = false;
const subject = observable.createSubject();
const observable$1 = functions.pipe(subject, op, observable.publish(scheduler, options));
disposable.addDisposable(observable$1, this);
disposable.addDisposable(this, subject);
this.dispatcher = subject;
this.observable = observable$1;
}
get type() {
return this;
}
get T() {
return undefined;
}
get observerCount() {

@@ -37,7 +28,14 @@ return this.observable.observerCount;

}
observe(observer) {
functions.pipe(this.observable, observable.observe(observer));
sink(observer) {
functions.pipe(this.observable, source.sinkInto(observer));
}
}
const createStream = (op, scheduler, options) => new StreamImpl(op, scheduler, options);
const createStream = (op, scheduler, options) => {
const subject = observable.createSubject();
const observable$1 = functions.pipe(subject, op, observable.publish(scheduler, options));
const stream = new StreamImpl(subject, observable$1);
disposable.addDisposable(observable$1, stream);
disposable.addDisposable(stream, subject);
return stream;
};

@@ -63,8 +61,9 @@ class StreamableImpl {

const src = streamable instanceof LiftedStreamable ? streamable.src : streamable;
const op = requests => observable.using(scheduler => {
const op = requests => observable.createObservableWithScheduler(scheduler => {
const srcStream = functions.pipe(src, stream(scheduler));
const requestSubscription = functions.pipe(requests, observable.map(functions.compose(...reqOps)), observable.subscribe(scheduler, srcStream.dispatch, srcStream));
disposable.bindDisposables(srcStream, requestSubscription);
return srcStream;
}, functions.compose(...obsOps));
disposable.addDisposable(scheduler, srcStream);
return functions.pipe(srcStream, functions.compose(...obsOps));
});
return new LiftedStreamable(op, src, obsOps, reqOps);

@@ -140,8 +139,9 @@ };

*/
const toStateStore = () => streamable => createStreamable(updates => observable.using(scheduler => {
const toStateStore = () => streamable => createStreamable(updates => observable.createObservableWithScheduler(scheduler => {
const stream$1 = functions.pipe(streamable, stream(scheduler));
const updatesSubscription = functions.pipe(updates, observable.zipWithLatestFrom(stream$1, (updateState, prev) => updateState(prev)), observable.subscribe(scheduler, stream$1.dispatch, stream$1));
disposable.bindDisposables(updatesSubscription, stream$1);
disposable.addDisposable(scheduler, stream$1);
return stream$1;
}, functions.identity));
}));

@@ -159,3 +159,3 @@ const _identity = {

const flow = ({ scheduler: scheduler$1, } = {}) => observable$1 => {
const createScheduler = (modeObs) => (modeScheduler) => {
const op = (modeObs) => observable.createObservableWithScheduler(modeScheduler => {
const pausableScheduler = scheduler.toPausableScheduler(scheduler$1 !== null && scheduler$1 !== void 0 ? scheduler$1 : modeScheduler);

@@ -174,5 +174,5 @@ const onModeChange = (mode) => {

disposable.bindDisposables(modeSubscription, pausableScheduler);
return pausableScheduler;
};
const op = (modeObs) => observable.using(createScheduler(modeObs), pausableScheduler => functions.pipe(observable$1, observable.subscribeOn(pausableScheduler), functions.pipe(pausableScheduler, observable.fromDisposable, observable.takeUntil)));
modeScheduler.add(pausableScheduler);
return functions.pipe(observable$1, observable.subscribeOn(pausableScheduler), functions.pipe(pausableScheduler, observable.fromDisposable, observable.takeUntil));
});
return createStreamable(op);

@@ -182,88 +182,22 @@ };

const ignoreAndNotifyVoid = functions.compose(container.ignoreElements(observable.keepT), container.endWith({ ...observable.fromArrayT, ...observable.concatT }, option.none));
const sink = (src, dest) => observable.using(scheduler => {
const srcStream = functions.pipe(src, stream(scheduler));
const destStream = functions.pipe(dest, stream(scheduler));
const srcSubscription = functions.pipe(srcStream, observable.subscribe(scheduler, destStream.dispatch, destStream));
const destSubscription = functions.pipe(destStream, observable.subscribe(scheduler, srcStream.dispatch, srcStream));
disposable.addDisposable(srcSubscription, destStream);
disposable.addDisposable(destSubscription, srcStream);
return destStream;
}, ignoreAndNotifyVoid);
const createSinkObs = (srcStream, destStream) => observable.merge(functions.pipe(srcStream, observable.onNotify(observable.dispatchTo(destStream)), container.ignoreElements(observable.keepT), observable.onSubscribe(() => destStream)), functions.pipe(destStream, observable.onNotify(observable.dispatchTo(srcStream)), container.ignoreElements(observable.keepT), observable.onSubscribe(() => srcStream)));
const sink = (src, dest) => functions.pipe(observable.observable(() => {
const srcStream = __stream(src);
const destStream = __stream(dest);
const obs = observable.__memo(createSinkObs, srcStream, destStream);
return observable.__observe(obs);
}), ignoreAndNotifyVoid);
const notifyEvent = (data) => ({
type: "notify",
data,
});
const doneEventWithData = (data) => ({
type: "done",
data,
});
const doneEvent = { type: "done" };
const decodeWithCharset = (charset = "utf-8", options) => functions.pipe(observable.withLatestFrom(container.compute({
...observable.fromArrayT,
...observable.mapT,
})(() => new TextDecoder(charset, options)), function* (ev, decoder) {
switch (ev.type) {
case "notify": {
const data = decoder.decode(ev.data, { stream: true });
if (data.length > 0) {
yield notifyEvent(data);
}
break;
}
case "done": {
const data = decoder.decode();
if (data.length > 0) {
yield notifyEvent(data);
}
yield doneEvent;
break;
}
}
}), functions.composeWith(observable.map(functions.returns)), functions.composeWith(container.concatMap({ ...observable.concatAllT, ...observable.mapT }, observable.fromIterator())), lift);
const _encodeUtf8 = lift(observable.withLatestFrom(container.compute({
...observable.fromArrayT,
...observable.mapT,
})(() => new TextEncoder()), (ev, textEncoder) => {
switch (ev.type) {
case "notify": {
const data = textEncoder.encode(ev.data);
return notifyEvent(data);
}
case "done": {
return ev;
}
}
}));
const encodeUtf8 = _encodeUtf8;
const mapIOEventStream = (mapper) => lift(observable.map((ev) => ev.type === "notify" ? functions.pipe(ev.data, mapper, notifyEvent) : ev));
const _flowIOEvents = functions.compose(observable.map(notifyEvent), container.endWith({ ...observable.fromArrayT, ...observable.concatT }, doneEvent), flow());
const flowIOEvents = () => _flowIOEvents;
const isNotify = (ev) => ev.type === "notify";
class IOSinkAccumulatorImpl extends disposable.AbstractDisposable {
constructor(reducer, initialValue, options) {
class FlowableSinkAccumulatorImpl extends source.AbstractDisposableSource {
constructor(subject, streamable) {
super();
this.subject = subject;
this.streamable = streamable;
this.isSynchronous = false;
const subject = observable.createSubject(options);
disposable.addDisposableDisposeParentOnChildError(this, subject);
const op = (events) => observable.using(scheduler => functions.pipe(events, observable.takeWhile(isNotify), container.keepType(observable.keepT, isNotify), observable.map(ev => ev.data), observable.reduce(reducer, initialValue), observable.subscribe(scheduler, subject.dispatch, subject)), eventsSubscription => observable.createObservable(dispatcher => {
dispatcher.dispatch("pause");
dispatcher.dispatch("resume");
disposable.addDisposable(eventsSubscription, dispatcher);
}));
this.streamable = createStreamable(op);
this.subject = subject;
}
get type() {
return this;
}
get T() {
return undefined;
}
get observerCount() {
return this.subject.observerCount;
}
observe(observer) {
this.subject.observe(observer);
sink(observer) {
this.subject.sink(observer);
}

@@ -277,3 +211,10 @@ stream(scheduler, options) {

/** @experimental */
const createIOSinkAccumulator = (reducer, initialValue, options) => new IOSinkAccumulatorImpl(reducer, initialValue, options);
const createFlowableSinkAccumulator = (reducer, initialValue, options) => {
const subject = observable.createSubject(options);
const op = (events) => functions.pipe(events, observable.reduce(reducer, initialValue), observable.onNotify(observable.dispatchTo(subject)), container.ignoreElements(observable.keepT), container.startWith({ ...observable.concatT, ...observable.fromArrayT }, "pause", "resume"));
const streamable = createStreamable(op);
const sinkAcc = new FlowableSinkAccumulatorImpl(subject, streamable);
disposable.addDisposableDisposeParentOnChildError(sinkAcc, subject);
return sinkAcc;
};

@@ -295,3 +236,3 @@ const fromArrayScanner = (acc, _) => acc + 1;

const _fromEnumerable = (enumerable$1) => createStreamable(functions.compose(observable.withLatestFrom(observable.using(_ => enumerable.enumerate(enumerable$1), functions.compose(container.fromValue(observable.fromArrayT), container.concatWith(observable.concatT, observable.never()))), (_, enumerator) => enumerator), observable.onNotify(enumerable.move), observable.takeWhile(enumerable.hasCurrent), observable.map(enumerable.current)));
const _fromEnumerable = (enumerable$1) => createStreamable(functions.compose(observable.withLatestFrom(observable.using(() => enumerable.enumerate(enumerable$1), functions.compose(container.fromValue(observable.fromArrayT), container.concatWith(observable.concatT, observable.never()))), (_, enumerator) => enumerator), observable.onNotify(enumerable.move), observable.takeWhile(enumerable.hasCurrent), observable.map(enumerable.current)));
/**

@@ -337,17 +278,29 @@ * Returns an `AsyncEnumerableLike` from the provided iterable.

const consumeImpl = (consumer, initial) => enumerable => observable.using(scheduler => {
const enumerator = functions.pipe(enumerable, stream(scheduler));
const accFeedback = observable.createSubject();
return [accFeedback, enumerator];
}, (accFeedback, enumerator) => functions.pipe(enumerator, consumer(accFeedback), observable.onNotify(ev => {
switch (ev.type) {
case "notify":
accFeedback.dispatch(ev.data);
enumerator.dispatch(option.none);
break;
}
}), observable.map(ev => ev.data), observable.onSubscribe(() => {
accFeedback.dispatch(initial());
enumerator.dispatch(option.none);
})));
const consumeContinue = (data) => ({
type: "continue",
data,
});
const consumeDone = (data) => ({
type: "done",
data,
});
const consumeImpl = (consumer, initial) => {
const createObservable = (accFeedback, enumerator) => functions.pipe(enumerator, consumer(accFeedback), observable.onNotify(ev => {
switch (ev.type) {
case "continue":
accFeedback.dispatch(ev.data);
enumerator.dispatch(option.none);
break;
}
}), observable.map(ev => ev.data), observable.onSubscribe(() => {
accFeedback.dispatch(initial());
enumerator.dispatch(option.none);
}));
return enumerable => observable.observable(() => {
const enumerator = __stream(enumerable);
const accFeedback = observable.__using(observable.createSubject);
const observable$1 = observable.__memo(createObservable, accFeedback, enumerator);
return observable.__observe(observable$1);
});
};
const consume = (consumer, initial) => consumeImpl(accObs => observable.zipWithLatestFrom(accObs, functions.flip(consumer)), initial);

@@ -359,13 +312,10 @@ const consumeAsync = (consumer, initial) => consumeImpl(accObs => functions.compose(observable.zipWithLatestFrom(accObs, (next, acc) => functions.pipe(consumer(acc, next), observable.takeFirst())), observable.switchAll()), initial);

exports.consumeAsync = consumeAsync;
exports.consumeContinue = consumeContinue;
exports.consumeDone = consumeDone;
exports.createActionReducer = createActionReducer;
exports.createIOSinkAccumulator = createIOSinkAccumulator;
exports.createFlowableSinkAccumulator = createFlowableSinkAccumulator;
exports.createStateStore = createStateStore;
exports.createStreamable = createStreamable;
exports.decodeWithCharset = decodeWithCharset;
exports.doneEvent = doneEvent;
exports.doneEventWithData = doneEventWithData;
exports.empty = empty;
exports.encodeUtf8 = encodeUtf8;
exports.flow = flow;
exports.flowIOEvents = flowIOEvents;
exports.fromArray = fromArray;

@@ -377,7 +327,5 @@ exports.fromEnumerable = fromEnumerable;

exports.lift = lift;
exports.mapIOEventStream = mapIOEventStream;
exports.mapReq = mapReq;
exports.notifyEvent = notifyEvent;
exports.sink = sink;
exports.stream = stream;
exports.toStateStore = toStateStore;

@@ -9,5 +9,5 @@ 'use strict';

var readonlyArray = require('./readonlyArray.js');
var container = require('./container.js');
var option = require('./option.js');
var streamable = require('./streamable.js');
var source = require('./source.js');

@@ -81,48 +81,7 @@ const fromEvent = (target, eventName, selector) => observable.createObservable(dispatcher => {

};
class WindowLocationStream extends container.AbstractContainer {
constructor(scheduler, options) {
class WindowLocationStream extends observable.AbstractObservable {
constructor(stateStream) {
super();
this.scheduler = scheduler;
this.options = options;
this.stateStream = stateStream;
this.historyCounter = -1;
this.stateStream = functions.pipe(() => ({
replace: true,
uri: getCurrentWindowLocationURI(),
}), streamable.createStateStore, streamable.lift(observable.onNotify(({ uri }) => {
// Initialize the history state on page load
const isInitialPageLoad = this.historyCounter === -1;
if (isInitialPageLoad) {
this.historyCounter === 0;
windowHistoryReplaceState(this, uri);
}
})), streamable.lift(observable.keep(({ uri }) => {
const { title } = uri;
const uriString = windowLocationURIToString(uri);
const titleChanged = document.title !== title;
const uriChanged = uriString !== window.location.href;
return titleChanged || uriChanged;
})), streamable.lift(observable.throttle(300)), streamable.lift(observable.onNotify(({ replace, uri }) => {
const { title } = uri;
const uriString = windowLocationURIToString(uri);
const titleChanged = document.title !== title;
const uriChanged = uriString !== window.location.href;
const shouldReplace = replace || (titleChanged && !uriChanged);
const updateHistoryState = shouldReplace
? windowHistoryReplaceState
: windowHistoryPushState;
document.title = title;
updateHistoryState(this, uri);
})), streamable.lift(observable.map(({ uri }) => uri)), streamable.stream(scheduler, options));
const historySubscription = functions.pipe(fromEvent(window, "popstate", (e) => {
const { counter, title } = e.state;
const uri = {
...getCurrentWindowLocationURI(),
title,
};
return { counter, uri };
}), observable.onNotify(({ counter, uri }) => {
this.historyCounter = counter;
this.dispatch(uri, { replace: true });
}), observable.subscribe(scheduler));
disposable.addDisposableDisposeParentOnChildError(this, historySubscription);
}

@@ -159,3 +118,3 @@ get error() {

dispose(error) {
this.stateStream.dispose(error);
functions.pipe(this.stateStream, disposable.dispose(error));
}

@@ -169,4 +128,4 @@ goBack() {

}
observe(observer) {
this.stateStream.observe(observer);
sink(observer) {
this.stateStream.sink(observer);
}

@@ -179,13 +138,47 @@ }

stream(scheduler, options) {
var _a;
let { currentStream } = this;
if (option.isNone(currentStream)) {
currentStream = new WindowLocationStream(scheduler, options);
this.currentStream = currentStream;
return currentStream;
const stateStream = functions.pipe(() => ({
replace: true,
uri: getCurrentWindowLocationURI(),
}), streamable.createStateStore, streamable.lift(observable.onNotify(({ uri }) => {
// Initialize the history state on page load
const isInitialPageLoad = windowLocationStream.historyCounter === -1;
if (isInitialPageLoad) {
windowLocationStream.historyCounter === 0;
windowHistoryReplaceState(windowLocationStream, uri);
}
})), streamable.lift(observable.keep(({ uri }) => {
const { title } = uri;
const uriString = windowLocationURIToString(uri);
const titleChanged = document.title !== title;
const uriChanged = uriString !== window.location.href;
return titleChanged || uriChanged;
})), streamable.lift(observable.throttle(300)), streamable.lift(observable.onNotify(({ replace, uri }) => {
const { title } = uri;
const uriString = windowLocationURIToString(uri);
const titleChanged = document.title !== title;
const uriChanged = uriString !== window.location.href;
const shouldReplace = replace || (titleChanged && !uriChanged);
const updateHistoryState = shouldReplace
? windowHistoryReplaceState
: windowHistoryPushState;
document.title = title;
updateHistoryState(windowLocationStream, uri);
})), streamable.lift(observable.map(({ uri }) => uri)), streamable.stream(scheduler, options));
const windowLocationStream = new WindowLocationStream(stateStream);
const historySubscription = functions.pipe(fromEvent(window, "popstate", (e) => {
const { counter, title } = e.state;
const uri = {
...getCurrentWindowLocationURI(),
title,
};
return { counter, uri };
}), observable.onNotify(({ counter, uri }) => {
windowLocationStream.historyCounter = counter;
windowLocationStream.dispatch(uri, { replace: true });
}), observable.subscribe(scheduler));
disposable.addDisposableDisposeParentOnChildError(windowLocationStream, historySubscription);
return windowLocationStream;
}
else if (currentStream.scheduler === scheduler &&
((_a = currentStream.options) === null || _a === void 0 ? void 0 : _a.replay) === (options === null || options === void 0 ? void 0 : options.replay)) {
return currentStream;
}
else {

@@ -199,3 +192,3 @@ return functions.raise("Cannot stream more than once");

const globalFetch = self.fetch;
const fetch = (onResponse) => fetchRequest => observable.defer(observer => async () => {
const fetch = (onResponse) => fetchRequest => observable.defer(() => async (observer) => {
const signal = disposable.toAbortSignal(observer);

@@ -217,3 +210,3 @@ let request = option.none;

: onResponseResult;
functions.pipe(resultObs, observable.observe(observer));
functions.pipe(resultObs, source.sinkInto(observer));
}

@@ -220,0 +213,0 @@ catch (cause) {

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

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