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.8.0 to 0.8.1

7

container.d.ts

@@ -29,2 +29,7 @@ import { AbstractDisposable, DisposableLike } from './disposable.js';

}
interface Buffer<C extends ContainerLike> extends Container<C> {
buffer: <T>(options?: {
readonly maxBufferSize?: number;
}) => ContainerOperator<C, T, readonly T[]>;
}
interface Concat<C extends ContainerLike> extends Container<C> {

@@ -154,2 +159,2 @@ concat<T>(fst: ContainerOf<C, T>, snd: ContainerOf<C, T>, ...tail: readonly ContainerOf<C, T>[]): ContainerOf<C, T>;

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 };
export { AbstractContainer, AbstractDisposableContainer, Buffer, 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 };

7

container.js

@@ -30,6 +30,3 @@ 'use strict';

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

@@ -45,3 +42,3 @@ function endWith(m, ...values) {

}));
const genMap = (m, mapper, options) => functions.compose(m.map(x => functions.pipe(functions.defer(x, mapper), m.fromIterator(options))), m.concatAll(options));
const genMap = (m, mapper, options) => functions.compose(m.map(x => functions.pipe(functions.pipeLazy(x, mapper), m.fromIterator(options))), m.concatAll(options));
const keepType = ({ keep }, predicate) => keep(predicate);

@@ -48,0 +45,0 @@ const ignoreElements = ({ keep, }) => keep(functions.alwaysFalse);

@@ -100,14 +100,2 @@ import { SideEffect1, Function1, SideEffect } from './functions.js';

/**
* Abstract base class for implementing the `SerialDisposableLike` interface.
*
* @noInheritDoc
* */
declare abstract class AbstractSerialDisposable extends AbstractDisposable implements SerialDisposableLike {
private _inner;
/** @ignore */
get inner(): DisposableLike;
/** @ignore */
set inner(newInner: DisposableLike);
}
/**
* Creates a new `SerialDisposableLike` instance containing a disposed instance.

@@ -132,2 +120,2 @@ */

export { AbstractDisposable, AbstractSerialDisposable, DisposableLike, DisposableOrTeardown, DisposableValueLike, Error, SerialDisposableLike, add, addTo, bindTo, createDisposable, createDisposableValue, createSerialDisposable, dispose, disposed, isDisposed, onComplete, onDisposed, onError, toAbortSignal, toErrorHandler };
export { AbstractDisposable, DisposableLike, DisposableOrTeardown, DisposableValueLike, Error, SerialDisposableLike, add, addTo, bindTo, createDisposable, createDisposableValue, createSerialDisposable, dispose, disposed, isDisposed, onComplete, onDisposed, onError, toAbortSignal, toErrorHandler };

@@ -149,8 +149,3 @@ 'use strict';

const disposed = _disposed;
/**
* Abstract base class for implementing the `SerialDisposableLike` interface.
*
* @noInheritDoc
* */
class AbstractSerialDisposable extends AbstractDisposable {
class SerialDisposableImpl extends AbstractDisposable {
constructor() {

@@ -174,4 +169,2 @@ super(...arguments);

}
class SerialDisposableImpl extends AbstractSerialDisposable {
}
/**

@@ -191,3 +184,3 @@ * Creates a new `SerialDisposableLike` instance containing a disposed instance.

*/
const createDisposableValue = (value, cleanup) => functions.pipe(new DisposableValueImpl(value), onDisposed(functions.defer(value, cleanup)));
const createDisposableValue = (value, cleanup) => functions.pipe(new DisposableValueImpl(value), onDisposed(functions.pipeLazy(value, cleanup)));
const toAbortSignal = (disposable) => {

@@ -200,3 +193,2 @@ const abortController = new AbortController();

exports.AbstractDisposable = AbstractDisposable;
exports.AbstractSerialDisposable = AbstractSerialDisposable;
exports.add = add;

@@ -203,0 +195,0 @@ exports.addTo = addTo;

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

import { 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 { Buffer, 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 { Enumerator } from './enumerator.js';

@@ -8,2 +8,7 @@ import { Factory, Function1, Updater, Predicate, Equality, SideEffect1, Reducer } from './functions.js';

declare const buffer: <T>(options?: {
readonly maxBufferSize?: number;
}) => EnumerableOperator<T, readonly T[]>;
declare const bufferT: Buffer<EnumerableLike<unknown>>;
declare abstract class AbstractEnumerable<T> extends AbstractLiftable<Enumerator<T>> implements EnumerableLike<T> {

@@ -103,3 +108,3 @@ abstract enumerate(this: EnumerableLike<T>): Enumerator<T>;

readonly type: EnumerableLike<this["T"]>;
readonly liftedStateType: Enumerator<this["T"]>;
readonly liftableStateType: Enumerator<this["T"]>;
/**

@@ -153,2 +158,2 @@ * Returns an `EnumeratorLike` to iterate through the Container.

export { AbstractEnumerable, EnumerableLike, EnumerableOperator, ToEnumerable, concat, concatAll, concatAllT, concatT, createEnumerable, distinctUntilChanged, distinctUntilChangedT, enumerate, fromArray, fromArrayT, fromIterable, fromIterableT, fromIterator, fromIteratorT, generate, generateT, keep, keepT, map, mapT, 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, zipT };
export { AbstractEnumerable, EnumerableLike, EnumerableOperator, ToEnumerable, buffer, bufferT, concat, concatAll, concatAllT, concatT, createEnumerable, distinctUntilChanged, distinctUntilChangedT, enumerate, fromArray, fromArrayT, fromIterable, fromIterableT, fromIterator, fromIteratorT, generate, generateT, keep, keepT, map, mapT, 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, zipT };

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

const liftT = {
variance: "covariant",
variance: liftable.covariant,
lift,

@@ -143,2 +143,35 @@ };

class BufferEnumerator extends enumerator.AbstractEnumerator {
constructor(delegate, maxBufferSize) {
super();
this.delegate = delegate;
this.maxBufferSize = maxBufferSize;
}
move() {
enumerator.reset(this);
const buffer = [];
const { delegate, maxBufferSize } = this;
while (buffer.length < maxBufferSize && delegate.move()) {
buffer.push(delegate.current);
}
const bufferLength = buffer.length;
if (bufferLength > 0) {
this.current = buffer;
}
if (bufferLength < maxBufferSize) {
functions.pipe(this, disposable.dispose());
}
return enumerator.hasCurrent(this);
}
}
const buffer = (options = {}) => {
var _a;
const maxBufferSize = Math.max((_a = options.maxBufferSize) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER, 1);
const operator = (delegate) => functions.pipe(new BufferEnumerator(delegate, maxBufferSize), disposable.add(delegate));
return lift(operator);
};
const bufferT = {
buffer,
};
class IteratorEnumerator extends enumerator.Enumerator {

@@ -355,3 +388,3 @@ constructor(iterator) {

*/
const _zip = (...enumerables) => createEnumerable(() => functions.pipe(enumerables, readonlyArray.map(enumerate), enumerator.zip));
const _zip = (...enumerables) => createEnumerable(() => functions.pipe(enumerables, readonlyArray.map(enumerate), a => enumerator.zip(...a)));
const zip = _zip;

@@ -370,3 +403,3 @@ const zipT = {

};
const distinctUntilChanged = liftable.createDistinctUntilChangedLiftedOperator(liftT, class DistinctUntilChangedEnumerator extends enumerator.AbstractDelegatingEnumerator {
const distinctUntilChanged = liftable.createDistinctUntilChangedLiftOperator(liftT, class DistinctUntilChangedEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor(delegate, equality) {

@@ -397,3 +430,3 @@ super(delegate);

};
const keep = liftable.createKeepLiftedOperator(liftT, class KeepEnumerator extends enumerator.AbstractDelegatingEnumerator {
const keep = liftable.createKeepLiftOperator(liftT, class KeepEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor(delegate, predicate) {

@@ -417,3 +450,3 @@ super(delegate);

};
const map = liftable.createMapLiftedOperator(liftT, class MapEnumerator extends enumerator.AbstractEnumerator {
const map = liftable.createMapLiftOperator(liftT, class MapEnumerator extends enumerator.AbstractEnumerator {
constructor(delegate, mapper) {

@@ -441,3 +474,3 @@ super();

};
const onNotify = liftable.createOnNotifyLiftedOperator(liftT, class OnNotifyEnumerator extends enumerator.AbstractDelegatingEnumerator {
const onNotify = liftable.createOnNotifyLiftOperator(liftT, class OnNotifyEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor(delegate, onNotify) {

@@ -460,3 +493,3 @@ super(delegate);

});
const pairwise = liftable.createPairwiseLiftedOperator(liftT, class PairwiseEnumerator extends enumerator.AbstractEnumerator {
const pairwise = liftable.createPairwiseLiftOperator(liftT, class PairwiseEnumerator extends enumerator.AbstractEnumerator {
constructor(delegate) {

@@ -480,3 +513,3 @@ super();

};
const scan = liftable.createScanLiftedOperator(liftT, class ScanEnumerator extends enumerator.AbstractEnumerator {
const scan = liftable.createScanLiftOperator(liftT, class ScanEnumerator extends enumerator.AbstractEnumerator {
constructor(delegate, reducer, current) {

@@ -506,3 +539,3 @@ super();

};
const skipFirst = liftable.createSkipFirstLiftedOperator(liftT, class SkipFirstEnumerator extends enumerator.AbstractDelegatingEnumerator {
const skipFirst = liftable.createSkipFirstLiftOperator(liftT, class SkipFirstEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor(delegate, skipCount) {

@@ -527,3 +560,3 @@ super(delegate);

};
const takeFirst = liftable.createTakeFirstLiftedOperator({ ...fromArrayT, ...liftT }, class TakeFirstEnumerator extends enumerator.AbstractDelegatingEnumerator {
const takeFirst = liftable.createTakeFirstLiftOperator({ ...fromArrayT, ...liftT }, class TakeFirstEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor(delegate, maxCount) {

@@ -535,3 +568,3 @@ super(delegate);

get current() {
return enumerator.current(this.delegate);
return enumerator.current(liftable.delegate(this));
}

@@ -541,3 +574,3 @@ move() {

this.count++;
enumerator.move(this.delegate);
enumerator.move(liftable.delegate(this));
}

@@ -553,3 +586,3 @@ else {

};
const takeWhile = liftable.createTakeWhileLiftedOperator(liftT, class TakeWhileEnumerator extends enumerator.AbstractDelegatingEnumerator {
const takeWhile = liftable.createTakeWhileLiftOperator(liftT, class TakeWhileEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor(delegate, predicate, inclusive) {

@@ -587,3 +620,3 @@ super(delegate);

};
const throwIfEmpty = liftable.createThrowIfEmptyLiftedOperator(liftT, class ThrowIfEmptyEnumerator extends enumerator.AbstractDelegatingEnumerator {
const throwIfEmpty = liftable.createThrowIfEmptyLiftOperator(liftT, class ThrowIfEmptyEnumerator extends enumerator.AbstractDelegatingEnumerator {
constructor() {

@@ -594,3 +627,3 @@ super(...arguments);

move() {
if (enumerator.move(this.delegate)) {
if (enumerator.move(liftable.delegate(this))) {
this.isEmpty = false;

@@ -618,2 +651,4 @@ }

exports.AbstractEnumerable = AbstractEnumerable;
exports.buffer = buffer;
exports.bufferT = bufferT;
exports.concat = concat;

@@ -620,0 +655,0 @@ exports.concatAll = concatAll;

import { AbstractDisposableContainer } from './container.js';
import { SideEffect1, Function1 } from './functions.js';
import { LiftedStateLike } from './liftable.js';
import { LiftableStateLike } from './liftable.js';
declare abstract class Enumerator<T> extends AbstractDisposableContainer implements LiftedStateLike {
declare abstract class Enumerator<T> extends AbstractDisposableContainer implements LiftableStateLike {
abstract get current(): T;

@@ -32,4 +32,12 @@ abstract get hasCurrent(): boolean;

declare const reset: <T>(enumerator: AbstractEnumerator<T>) => void;
declare const zip: <T>(enumerators: readonly Enumerator<T>[]) => Enumerator<readonly T[]>;
declare function zip<TA, TB>(a: Enumerator<TA>, b: Enumerator<TB>): Enumerator<readonly [TA, TB]>;
declare function zip<TA, TB, TC>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>): Enumerator<readonly [TA, TB, TC]>;
declare function zip<TA, TB, TC, TD>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>, d: Enumerator<TD>): Enumerator<readonly [TA, TB, TC, TD]>;
declare function zip<TA, TB, TC, TD, TE>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>, d: Enumerator<TD>, e: Enumerator<TE>): Enumerator<readonly [TA, TB, TC, TD, TE]>;
declare function zip<TA, TB, TC, TD, TE, TF>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>, d: Enumerator<TD>, e: Enumerator<TE>, f: Enumerator<TF>): Enumerator<readonly [TA, TB, TC, TD, TE, TF]>;
declare function zip<TA, TB, TC, TD, TE, TF, TG>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>, d: Enumerator<TD>, e: Enumerator<TE>, f: Enumerator<TF>, g: Enumerator<TG>): Enumerator<readonly [TA, TB, TC, TD, TE, TF, TG]>;
declare function zip<TA, TB, TC, TD, TE, TF, TG, TH>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>, d: Enumerator<TD>, e: Enumerator<TE>, f: Enumerator<TF>, g: Enumerator<TG>, h: Enumerator<TH>): Enumerator<readonly [TA, TB, TC, TD, TE, TF, TG, TH]>;
declare function zip<TA, TB, TC, TD, TE, TF, TG, TH, TI>(a: Enumerator<TA>, b: Enumerator<TB>, c: Enumerator<TC>, d: Enumerator<TD>, e: Enumerator<TE>, f: Enumerator<TF>, g: Enumerator<TG>, h: Enumerator<TH>, i: Enumerator<TI>): Enumerator<readonly [TA, TB, TC, TD, TE, TF, TG, TH, TI]>;
declare function zip<T>(...enumerators: readonly Enumerator<T>[]): Enumerator<readonly T[]>;
export { AbstractDelegatingEnumerator, AbstractEnumerator, Enumerator, current, forEach, hasCurrent, move, reset, zip };

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

this._hasCurrent = false;
functions.pipe(this, disposable.onDisposed(functions.defer(this, reset)));
functions.pipe(this, disposable.onDisposed(functions.pipeLazy(this, reset)));
}

@@ -86,7 +86,7 @@ get current() {

}
const zip = (enumerators) => {
function zip(...enumerators) {
const enumerator = new ZipEnumerator(enumerators);
functions.pipe(enumerators, readonlyArray.forEach(disposable.addTo(enumerator)));
return enumerator;
};
}

@@ -93,0 +93,0 @@ exports.AbstractDelegatingEnumerator = AbstractDelegatingEnumerator;

@@ -159,3 +159,5 @@ /**

*/
declare const isEqualTo: <T>(b: T, equality?: Equality<T>) => Predicate<T>;
declare const isEqualTo: <T>(b: T, options?: {
equality?: Equality<T> | undefined;
}) => Predicate<T>;
/**

@@ -191,3 +193,3 @@ * Returns `true` if `x` is an even number, otherwise `false`.

*/
declare const updaterReducer: <T>(acc: T, updater: Updater<T>) => T;
declare const updateReducer: <T>(acc: T, updater: Updater<T>) => T;
declare function pipe<T, A>(src: T, op1: Function1<T, A>): A;

@@ -217,18 +219,18 @@ declare function pipe<T, A, B>(src: T, op1: Function1<T, A>, op2: Function1<A, B>): B;

declare function compose<T, A, B, C, D, E, F, G, H, I, J, K, L>(op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>, op11: Function1<J, K>, op12: Function1<K, L>): Function1<T, L>;
declare function defer<T, A>(src: T, op1: Function1<T, A>): Factory<A>;
declare function defer<T, A, B>(src: T, op1: Function1<T, A>, op2: Function1<A, B>): Factory<B>;
declare function defer<T, A, B, C>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>): Factory<C>;
declare function defer<T, A, B, C, D>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>): Factory<D>;
declare function defer<T, A, B, C, D, E>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>): Factory<E>;
declare function defer<T, A, B, C, D, E, F>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>): Factory<F>;
declare function defer<T, A, B, C, D, E, F, G>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>): Factory<G>;
declare function defer<T, A, B, C, D, E, F, G, H>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>): Factory<H>;
declare function defer<T, A, B, C, D, E, F, G, H, I>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>): Factory<I>;
declare function defer<T, A, B, C, D, E, F, G, H, I, J>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>): Factory<J>;
declare function defer<T, A, B, C, D, E, F, G, H, I, J, K>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>, op11: Function1<J, K>): Factory<K>;
declare function defer<T, A, B, C, D, E, F, G, H, I, J, K, L>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>, op11: Function1<J, K>, op12: Function1<K, L>): Factory<L>;
declare function defer(source: unknown, ...operators: Function1<any, unknown>[]): Factory<unknown>;
declare function pipeLazy<T, A>(src: T, op1: Function1<T, A>): Factory<A>;
declare function pipeLazy<T, A, B>(src: T, op1: Function1<T, A>, op2: Function1<A, B>): Factory<B>;
declare function pipeLazy<T, A, B, C>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>): Factory<C>;
declare function pipeLazy<T, A, B, C, D>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>): Factory<D>;
declare function pipeLazy<T, A, B, C, D, E>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>): Factory<E>;
declare function pipeLazy<T, A, B, C, D, E, F>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>): Factory<F>;
declare function pipeLazy<T, A, B, C, D, E, F, G>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>): Factory<G>;
declare function pipeLazy<T, A, B, C, D, E, F, G, H>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>): Factory<H>;
declare function pipeLazy<T, A, B, C, D, E, F, G, H, I>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>): Factory<I>;
declare function pipeLazy<T, A, B, C, D, E, F, G, H, I, J>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>): Factory<J>;
declare function pipeLazy<T, A, B, C, D, E, F, G, H, I, J, K>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>, op11: Function1<J, K>): Factory<K>;
declare function pipeLazy<T, A, B, C, D, E, F, G, H, I, J, K, L>(src: T, op1: Function1<T, A>, op2: Function1<A, B>, op3: Function1<B, C>, op4: Function1<C, D>, op5: Function1<D, E>, op6: Function1<E, F>, op7: Function1<F, G>, op8: Function1<G, H>, op9: Function1<H, I>, op10: Function1<I, J>, op11: Function1<J, K>, op12: Function1<K, L>): Factory<L>;
declare function pipeLazy(source: unknown, ...operators: Function1<any, unknown>[]): Factory<unknown>;
declare function flip<TA, TB, T>(f: Function2<TA, TB, T>): Function2<TB, TA, T>;
declare function flip<TA, TB, TC, T>(f: Function3<TA, TB, TC, T>): Function3<TC, TB, TA, T>;
export { Comparator, Equality, Factory, Function1, Function2, Function3, Function4, Function5, Function6, Function7, Function8, Function9, Predicate, Reducer, SideEffect, SideEffect1, SideEffect2, SideEffect3, SideEffect4, SideEffect5, SideEffect6, SideEffect7, TypePredicate, Updater, alwaysFalse, alwaysTrue, arrayEquality, callWith, compose, decrement, decrementBy, defer, flip, identity, ignore, increment, incrementBy, isEqualTo, isEven, isOdd, negate, pipe, raise, returns, strictEquality, sum, updaterReducer };
export { Comparator, Equality, Factory, Function1, Function2, Function3, Function4, Function5, Function6, Function7, Function8, Function9, Predicate, Reducer, SideEffect, SideEffect1, SideEffect2, SideEffect3, SideEffect4, SideEffect5, SideEffect6, SideEffect7, TypePredicate, Updater, alwaysFalse, alwaysTrue, arrayEquality, callWith, compose, decrement, decrementBy, flip, identity, ignore, increment, incrementBy, isEqualTo, isEven, isOdd, negate, pipe, pipeLazy, raise, returns, strictEquality, sum, updateReducer };

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

var option = require('./option.js');
/**

@@ -66,3 +64,9 @@ * A function operator that invokes a function with a given list of arguments.

*/
const isEqualTo = (b, equality = strictEquality) => equality === strictEquality ? isStrictlyEqualTo(b) : (a) => equality(a, b);
const isEqualTo = (b, options = { equality: strictEquality }) => {
var _a;
const equality = (_a = options.equality) !== null && _a !== void 0 ? _a : strictEquality;
return equality === strictEquality
? isStrictlyEqualTo(b)
: (a) => equality(a, b);
};
/**

@@ -84,3 +88,3 @@ * Returns `true` if `x` is an even number, otherwise `false`.

const raise = (message) => {
if (option.isNone(message) || typeof message === "string") {
if (message === undefined || typeof message === "string") {
throw new Error(message);

@@ -112,3 +116,3 @@ }

*/
const updaterReducer = (acc, updater) => updater(acc);
const updateReducer = (acc, updater) => updater(acc);
/**

@@ -118,3 +122,3 @@ * Pipes `source` through a series of unary functions.

function pipe(source, ...operators) {
return operators.reduce(updaterReducer, source);
return operators.reduce(updateReducer, source);
}

@@ -128,6 +132,6 @@ /**

/**
* Returns a `Factory` function that defers the evaluation of piping
* Returns a `Factory` function that pipeLazys the evaluation of piping
* `source` through the provided operators.
*/
function defer(source, ...operators) {
function pipeLazy(source, ...operators) {
return () => pipe(source, ...operators);

@@ -152,3 +156,2 @@ }

exports.decrementBy = decrementBy;
exports.defer = defer;
exports.flip = flip;

@@ -164,2 +167,3 @@ exports.identity = identity;

exports.pipe = pipe;
exports.pipeLazy = pipeLazy;
exports.raise = raise;

@@ -169,2 +173,2 @@ exports.returns = returns;

exports.sum = sum;
exports.updaterReducer = updaterReducer;
exports.updateReducer = updateReducer;

@@ -6,54 +6,63 @@ import { ContainerLike, AbstractContainer, AbstractDisposableContainer, Container, ContainerOperator, FromArray, FromArrayOptions } from './container.js';

interface LiftedStateLike extends DisposableLike, ContainerLike {
interface LiftableStateLike extends DisposableLike, ContainerLike {
}
interface LiftableLike extends ContainerLike {
readonly liftedStateType: LiftedStateLike;
readonly liftableStateType: LiftableStateLike;
}
declare abstract class AbstractLiftable<TState extends LiftedStateLike> extends AbstractContainer implements LiftableLike {
get liftedStateType(): TState;
declare abstract class AbstractLiftable<TState extends LiftableStateLike> extends AbstractContainer implements LiftableLike {
get liftableStateType(): TState;
}
declare abstract class AbstractDisposableLiftable<TState extends LiftedStateLike> extends AbstractDisposableContainer implements LiftableLike {
get liftedStateType(): TState;
declare abstract class AbstractDisposableLiftable<TState extends LiftableStateLike> extends AbstractDisposableContainer implements LiftableLike {
get liftableStateType(): TState;
}
declare type LiftedStateOf<C extends LiftableLike, T> = C extends {
readonly liftedStateType: unknown;
declare type LiftableStateOf<C extends LiftableLike, T> = C extends {
readonly liftableStateType: unknown;
} ? (C & {
readonly T: T;
})["liftedStateType"] : {
})["liftableStateType"] : {
readonly _C: C;
readonly _T: () => T;
};
interface Lift<C extends LiftableLike, TVariance extends "covariant" | "contravariant"> extends Container<C> {
declare type DelegatingLiftableStateOf<C extends LiftableLike, T, TDelegate, TDelegateLiftableState extends LiftableStateOf<C, TDelegate> = LiftableStateOf<C, TDelegate>> = LiftableStateOf<C, T> & {
readonly delegate: TDelegateLiftableState;
};
declare const delegate: <C extends LiftableLike, T, TDelegate, TDelegateLiftableState extends LiftableStateOf<C, TDelegate> = LiftableStateOf<C, TDelegate>>(s: DelegatingLiftableStateOf<C, T, TDelegate, TDelegateLiftableState>) => TDelegateLiftableState;
declare type Covariant = 0;
declare const covariant: Covariant;
declare type ContraVariant = 1;
declare const contraVariant: ContraVariant;
declare type Variance = Covariant | ContraVariant;
interface Lift<C extends LiftableLike, TVariance extends Variance> extends Container<C> {
variance: TVariance;
lift<TA, TB>(operator: LiftOperator<C, TA, TB, this>): ContainerOperator<C, TA, TB>;
}
declare const lift: <C extends LiftableLike, TA, TB, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>) => Function1<LiftOperator<C, TA, TB, Lift<C, TVariance>>, ContainerOperator<C, TA, TB>>;
declare type LiftOperator<C extends LiftableLike, TA, TB, M extends Lift<C, "covariant" | "contravariant">> = Function1<LiftOperatorIn<C, TA, TB, M>, LiftOperatorOut<C, TA, TB, M>>;
declare type LiftOperatorIn<C extends LiftableLike, TA, TB, M extends Lift<C, "covariant" | "contravariant">> = M extends {
variance?: "contravariant";
} ? LiftedStateOf<C, TB> : LiftedStateOf<C, TA>;
declare type LiftOperatorOut<C extends LiftableLike, TA, TB, M extends Lift<C, "covariant" | "contravariant">> = M extends {
variance?: "contravariant";
} ? LiftedStateOf<C, TA> : LiftedStateOf<C, TB>;
declare const createDistinctUntilChangedLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, DistinctUntilChangedLiftableState: new <T>(delegate: LiftedStateOf<C, T>, equality: Equality<T>) => LiftedStateOf<C, T>) => <T_1>(options?: {
declare const lift: <C extends LiftableLike, TA, TB, TVariance extends Variance>(m: Lift<C, TVariance>) => Function1<LiftOperator<C, TA, TB, Lift<C, TVariance>>, ContainerOperator<C, TA, TB>>;
declare type LiftOperator<C extends LiftableLike, TA, TB, M extends Lift<C, Variance>> = Function1<LiftOperatorIn<C, TA, TB, M>, LiftOperatorOut<C, TA, TB, M>>;
declare type LiftOperatorIn<C extends LiftableLike, TA, TB, M extends Lift<C, Variance>> = M extends {
variance?: ContraVariant;
} ? LiftableStateOf<C, TB> : LiftableStateOf<C, TA>;
declare type LiftOperatorOut<C extends LiftableLike, TA, TB, M extends Lift<C, Variance>> = M extends {
variance?: ContraVariant;
} ? LiftableStateOf<C, TA> : LiftableStateOf<C, TB>;
declare const createDistinctUntilChangedLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, DistinctUntilChangedLiftableState: new <T>(delegate: LiftableStateOf<C, T>, equality: Equality<T>) => LiftableStateOf<C, T>) => <T_1>(options?: {
readonly equality?: Equality<T_1> | undefined;
}) => ContainerOperator<C, T_1, T_1>;
declare const createKeepLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, KeepLiftableState: new <T>(delegate: LiftedStateOf<C, T>, predicate: Predicate<T>) => LiftedStateOf<C, T>) => <T_1>(predicate: Predicate<T_1>) => ContainerOperator<C, T_1, T_1>;
declare const createMapLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, MapLiftableState: new <TA, TB>(delegate: LiftOperatorIn<C, TA, TB, Lift<C, TVariance>>, mapper: Function1<TA, TB>) => LiftOperatorOut<C, TA, TB, Lift<C, TVariance>>) => <TA_1, TB_1>(mapper: Function1<TA_1, TB_1>) => ContainerOperator<C, TA_1, TB_1>;
declare const createOnNotifyLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, OnNotifyLiftableState: new <T>(delegate: LiftedStateOf<C, T>, onNotify: SideEffect1<T>) => LiftedStateOf<C, T>) => <T_1>(onNotify: SideEffect1<T_1>) => ContainerOperator<C, T_1, T_1>;
declare const createPairwiseLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, PairwiseLiftableState: new <T>(delegate: LiftOperatorIn<C, T, [Option<T>, T], Lift<C, TVariance>>) => LiftOperatorOut<C, T, [Option<T>, T], Lift<C, TVariance>>) => <T_1>() => ContainerOperator<C, T_1, [Option<T_1>, T_1]>;
declare const createScanLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, ScanLiftableState: new <T, TAcc>(delegate: LiftOperatorIn<C, T, TAcc, Lift<C, TVariance>>, reducer: Reducer<T, TAcc>, acc: TAcc) => LiftOperatorOut<C, T, TAcc, Lift<C, TVariance>>) => <T_1, TAcc_1>(reducer: Reducer<T_1, TAcc_1>, initialValue: Factory<TAcc_1>) => ContainerOperator<C, T_1, TAcc_1>;
declare const createSkipFirstLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, SkipLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, Lift<C, TVariance>>, skipCount: number) => LiftOperatorOut<C, T, T, Lift<C, TVariance>>) => <T_1>(options?: {
declare const createKeepLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, KeepLiftableState: new <T>(delegate: LiftableStateOf<C, T>, predicate: Predicate<T>) => LiftableStateOf<C, T>) => <T_1>(predicate: Predicate<T_1>) => ContainerOperator<C, T_1, T_1>;
declare const createMapLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, MapLiftableState: new <TA, TB>(delegate: LiftOperatorIn<C, TA, TB, Lift<C, TVariance>>, mapper: Function1<TA, TB>) => LiftOperatorOut<C, TA, TB, Lift<C, TVariance>>) => <TA_1, TB_1>(mapper: Function1<TA_1, TB_1>) => ContainerOperator<C, TA_1, TB_1>;
declare const createOnNotifyLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, OnNotifyLiftableState: new <T>(delegate: LiftableStateOf<C, T>, onNotify: SideEffect1<T>) => LiftableStateOf<C, T>) => <T_1>(onNotify: SideEffect1<T_1>) => ContainerOperator<C, T_1, T_1>;
declare const createPairwiseLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, PairwiseLiftableState: new <T>(delegate: LiftOperatorIn<C, T, [Option<T>, T], Lift<C, TVariance>>) => LiftOperatorOut<C, T, [Option<T>, T], Lift<C, TVariance>>) => <T_1>() => ContainerOperator<C, T_1, [Option<T_1>, T_1]>;
declare const createScanLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, ScanLiftableState: new <T, TAcc>(delegate: LiftOperatorIn<C, T, TAcc, Lift<C, TVariance>>, reducer: Reducer<T, TAcc>, acc: TAcc) => LiftOperatorOut<C, T, TAcc, Lift<C, TVariance>>) => <T_1, TAcc_1>(reducer: Reducer<T_1, TAcc_1>, initialValue: Factory<TAcc_1>) => ContainerOperator<C, T_1, TAcc_1>;
declare const createSkipFirstLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, SkipLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, Lift<C, TVariance>>, skipCount: number) => LiftOperatorOut<C, T, T, Lift<C, TVariance>>) => <T_1>(options?: {
readonly count?: number;
}) => ContainerOperator<C, T_1, T_1>;
declare const createTakeFirstLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: FromArray<C, FromArrayOptions> & Lift<C, TVariance>, TakeFirstLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, FromArray<C, FromArrayOptions> & Lift<C, TVariance>>, maxCount: number) => LiftOperatorOut<C, T, T, FromArray<C, FromArrayOptions> & Lift<C, TVariance>>) => <T_1>(options?: {
declare const createTakeFirstLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: FromArray<C, FromArrayOptions> & Lift<C, TVariance>, TakeFirstLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, FromArray<C, FromArrayOptions> & Lift<C, TVariance>>, maxCount: number) => LiftOperatorOut<C, T, T, FromArray<C, FromArrayOptions> & Lift<C, TVariance>>) => <T_1>(options?: {
readonly count?: number;
}) => ContainerOperator<C, T_1, T_1>;
declare const createTakeWhileLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, TakeWhileLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, Lift<C, TVariance>>, predicate: Predicate<T>, inclusive: boolean) => LiftOperatorOut<C, T, T, Lift<C, TVariance>>) => <T_1>(predicate: Predicate<T_1>, options?: {
declare const createTakeWhileLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, TakeWhileLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, Lift<C, TVariance>>, predicate: Predicate<T>, inclusive: boolean) => LiftOperatorOut<C, T, T, Lift<C, TVariance>>) => <T_1>(predicate: Predicate<T_1>, options?: {
readonly inclusive?: boolean;
}) => ContainerOperator<C, T_1, T_1>;
declare const createThrowIfEmptyLiftedOperator: <C extends LiftableLike, TVariance extends "covariant" | "contravariant">(m: Lift<C, TVariance>, ThrowIfEmptyLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, Lift<C, TVariance>>) => LiftOperatorOut<C, T, T, Lift<C, TVariance>> & {
declare const createThrowIfEmptyLiftOperator: <C extends LiftableLike, TVariance extends Variance>(m: Lift<C, TVariance>, ThrowIfEmptyLiftableState: new <T>(delegate: LiftOperatorIn<C, T, T, Lift<C, TVariance>>) => LiftOperatorOut<C, T, T, Lift<C, TVariance>> & {
readonly isEmpty: boolean;
}) => <T_1>(factory: Factory<unknown>) => ContainerOperator<C, T_1, T_1>;
export { AbstractDisposableLiftable, AbstractLiftable, Lift, LiftOperator, LiftOperatorIn, LiftOperatorOut, LiftableLike, LiftedStateLike, LiftedStateOf, createDistinctUntilChangedLiftedOperator, createKeepLiftedOperator, createMapLiftedOperator, createOnNotifyLiftedOperator, createPairwiseLiftedOperator, createScanLiftedOperator, createSkipFirstLiftedOperator, createTakeFirstLiftedOperator, createTakeWhileLiftedOperator, createThrowIfEmptyLiftedOperator, lift };
export { AbstractDisposableLiftable, AbstractLiftable, ContraVariant, Covariant, DelegatingLiftableStateOf, Lift, LiftOperator, LiftOperatorIn, LiftOperatorOut, LiftableLike, LiftableStateLike, LiftableStateOf, Variance, contraVariant, covariant, createDistinctUntilChangedLiftOperator, createKeepLiftOperator, createMapLiftOperator, createOnNotifyLiftOperator, createPairwiseLiftOperator, createScanLiftOperator, createSkipFirstLiftOperator, createTakeFirstLiftOperator, createTakeWhileLiftOperator, createThrowIfEmptyLiftOperator, delegate, lift };

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

class AbstractLiftable extends container.AbstractContainer {
get liftedStateType() {
get liftableStateType() {
return functions.raise();

@@ -17,8 +17,11 @@ }

class AbstractDisposableLiftable extends container.AbstractDisposableContainer {
get liftedStateType() {
get liftableStateType() {
return functions.raise();
}
}
const delegate = (s) => s.delegate;
const covariant = 0;
const contraVariant = 1;
const lift = (m) => op => m.lift(op);
const createDistinctUntilChangedLiftedOperator = (m, DistinctUntilChangedLiftableState) => (options = {}) => {
const createDistinctUntilChangedLiftOperator = (m, DistinctUntilChangedLiftableState) => (options = {}) => {
const { equality = functions.strictEquality } = options;

@@ -28,11 +31,11 @@ const operator = delegate => functions.pipe(new DistinctUntilChangedLiftableState(delegate, equality), disposable.bindTo(delegate));

};
const createKeepLiftedOperator = (m, KeepLiftableState) => (predicate) => {
const createKeepLiftOperator = (m, KeepLiftableState) => (predicate) => {
const operator = (delegate) => functions.pipe(new KeepLiftableState(delegate, predicate), disposable.bindTo(delegate));
return functions.pipe(operator, lift(m));
};
const createMapLiftedOperator = (m, MapLiftableState) => (mapper) => functions.pipe((delegate) => functions.pipe(new MapLiftableState(delegate, mapper), disposable.bindTo(delegate)), lift(m));
const createOnNotifyLiftedOperator = (m, OnNotifyLiftableState) => (onNotify) => functions.pipe((delegate) => functions.pipe(new OnNotifyLiftableState(delegate, onNotify), disposable.bindTo(delegate)), lift(m));
const createPairwiseLiftedOperator = (m, PairwiseLiftableState) => () => functions.pipe((delegate) => functions.pipe(new PairwiseLiftableState(delegate), disposable.bindTo(delegate)), lift(m));
const createScanLiftedOperator = (m, ScanLiftableState) => (reducer, initialValue) => functions.pipe((delegate) => functions.pipe(new ScanLiftableState(delegate, reducer, initialValue()), disposable.bindTo(delegate)), lift(m));
const createSkipFirstLiftedOperator = (m, SkipLiftableState) => (options = {}) => {
const createMapLiftOperator = (m, MapLiftableState) => (mapper) => functions.pipe((delegate) => functions.pipe(new MapLiftableState(delegate, mapper), disposable.bindTo(delegate)), lift(m));
const createOnNotifyLiftOperator = (m, OnNotifyLiftableState) => (onNotify) => functions.pipe((delegate) => functions.pipe(new OnNotifyLiftableState(delegate, onNotify), disposable.bindTo(delegate)), lift(m));
const createPairwiseLiftOperator = (m, PairwiseLiftableState) => () => functions.pipe((delegate) => functions.pipe(new PairwiseLiftableState(delegate), disposable.bindTo(delegate)), lift(m));
const createScanLiftOperator = (m, ScanLiftableState) => (reducer, initialValue) => functions.pipe((delegate) => functions.pipe(new ScanLiftableState(delegate, reducer, initialValue()), disposable.bindTo(delegate)), lift(m));
const createSkipFirstLiftOperator = (m, SkipLiftableState) => (options = {}) => {
const { count = 1 } = options;

@@ -43,3 +46,3 @@ const operator = delegate => functions.pipe(new SkipLiftableState(delegate, count), disposable.bindTo(delegate));

};
const createTakeFirstLiftedOperator = (m, TakeFirstLiftableState) => (options = {}) => {
const createTakeFirstLiftOperator = (m, TakeFirstLiftableState) => (options = {}) => {
var _a;

@@ -51,12 +54,12 @@ const { count = Math.max((_a = options.count) !== null && _a !== void 0 ? _a : 1, 0) } = options;

};
const createTakeWhileLiftedOperator = (m, TakeWhileLiftableState) => (predicate, options = {}) => {
const createTakeWhileLiftOperator = (m, TakeWhileLiftableState) => (predicate, options = {}) => {
const { inclusive = false } = options;
return functions.pipe((delegate) => {
const lifted = functions.pipe(new TakeWhileLiftableState(delegate, predicate, inclusive), m.variance === "covariant" ? disposable.add(delegate) : disposable.addTo(delegate));
const lifted = functions.pipe(new TakeWhileLiftableState(delegate, predicate, inclusive), disposable.bindTo(delegate));
return lifted;
}, lift(m));
};
const createThrowIfEmptyLiftedOperator = (m, ThrowIfEmptyLiftableState) => (factory) => functions.pipe((delegate) => {
const lifted = functions.pipe(new ThrowIfEmptyLiftableState(delegate), m.variance === "covariant" ? disposable.add(delegate, true) : disposable.addTo(delegate));
const { parent, child } = m.variance === "covariant"
const createThrowIfEmptyLiftOperator = (m, ThrowIfEmptyLiftableState) => (factory) => functions.pipe((delegate) => {
const lifted = functions.pipe(new ThrowIfEmptyLiftableState(delegate), m.variance === covariant ? disposable.add(delegate, true) : disposable.addTo(delegate));
const { parent, child } = m.variance === covariant
? { parent: lifted, child: delegate }

@@ -83,12 +86,15 @@ : { parent: delegate, child: lifted };

exports.AbstractLiftable = AbstractLiftable;
exports.createDistinctUntilChangedLiftedOperator = createDistinctUntilChangedLiftedOperator;
exports.createKeepLiftedOperator = createKeepLiftedOperator;
exports.createMapLiftedOperator = createMapLiftedOperator;
exports.createOnNotifyLiftedOperator = createOnNotifyLiftedOperator;
exports.createPairwiseLiftedOperator = createPairwiseLiftedOperator;
exports.createScanLiftedOperator = createScanLiftedOperator;
exports.createSkipFirstLiftedOperator = createSkipFirstLiftedOperator;
exports.createTakeFirstLiftedOperator = createTakeFirstLiftedOperator;
exports.createTakeWhileLiftedOperator = createTakeWhileLiftedOperator;
exports.createThrowIfEmptyLiftedOperator = createThrowIfEmptyLiftedOperator;
exports.contraVariant = contraVariant;
exports.covariant = covariant;
exports.createDistinctUntilChangedLiftOperator = createDistinctUntilChangedLiftOperator;
exports.createKeepLiftOperator = createKeepLiftOperator;
exports.createMapLiftOperator = createMapLiftOperator;
exports.createOnNotifyLiftOperator = createOnNotifyLiftOperator;
exports.createPairwiseLiftOperator = createPairwiseLiftOperator;
exports.createScanLiftOperator = createScanLiftOperator;
exports.createSkipFirstLiftOperator = createSkipFirstLiftOperator;
exports.createTakeFirstLiftOperator = createTakeFirstLiftOperator;
exports.createTakeWhileLiftOperator = createTakeWhileLiftOperator;
exports.createThrowIfEmptyLiftOperator = createThrowIfEmptyLiftOperator;
exports.delegate = delegate;
exports.lift = lift;

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

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

@@ -37,10 +37,10 @@

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>;
declare const transform: (factory: Factory<DisposableValueLike<Transform>>) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
declare const brotliDecompress: (options?: BrotliOptions) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
declare const gunzip: (options?: ZlibOptions) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
declare const inflate: (options?: ZlibOptions) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
declare const brotliCompress: (options?: BrotliOptions) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
declare const gzip: (options?: ZlibOptions) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
declare const deflate: (options?: ZlibOptions) => Function1<FlowableLike<Uint8Array>, FlowableLike<Uint8Array>>;
export { bindNodeCallback, brotliCompress, brotliDecompress, createDisposableNodeStream, createReadableIOSource, createWritableIOSink, deflate, gunzip, gzip, inflate, readFileIOSource, transform };

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

}));
const onDrain = functions.defer("resume", dispatcher.dispatchTo(dispatcher$1));
const onFinish = functions.defer(dispatcher$1, disposable.dispose());
const onPause = functions.defer("pause", dispatcher.dispatchTo(dispatcher$1));
const onDrain = functions.pipeLazy("resume", dispatcher.dispatchTo(dispatcher$1));
const onFinish = functions.pipeLazy(dispatcher$1, disposable.dispose());
const onPause = functions.pipeLazy("pause", dispatcher.dispatchTo(dispatcher$1));
writableValue.on("drain", onDrain);

@@ -111,8 +111,8 @@ writableValue.on("finish", onFinish);

}));
const brotliDecompress = (options = {}) => transform(functions.defer(options, zlib.createBrotliDecompress, createDisposableNodeStream));
const gunzip = (options = {}) => transform(functions.defer(options, zlib.createGunzip, createDisposableNodeStream));
const inflate = (options = {}) => transform(functions.defer(options, zlib.createInflate, createDisposableNodeStream));
const brotliCompress = (options = {}) => transform(functions.defer(options, zlib.createBrotliCompress, createDisposableNodeStream));
const gzip = (options = {}) => transform(functions.defer(options, zlib.createGzip, createDisposableNodeStream));
const deflate = (options = {}) => transform(functions.defer(options, zlib.createDeflate, createDisposableNodeStream));
const brotliDecompress = (options = {}) => transform(functions.pipeLazy(options, zlib.createBrotliDecompress, createDisposableNodeStream));
const gunzip = (options = {}) => transform(functions.pipeLazy(options, zlib.createGunzip, createDisposableNodeStream));
const inflate = (options = {}) => transform(functions.pipeLazy(options, zlib.createInflate, createDisposableNodeStream));
const brotliCompress = (options = {}) => transform(functions.pipeLazy(options, zlib.createBrotliCompress, createDisposableNodeStream));
const gzip = (options = {}) => transform(functions.pipeLazy(options, zlib.createGzip, createDisposableNodeStream));
const deflate = (options = {}) => transform(functions.pipeLazy(options, zlib.createDeflate, createDisposableNodeStream));

@@ -119,0 +119,0 @@ exports.bindNodeCallback = bindNodeCallback;

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

import { Concat, FromArray, FromIterator, FromIterable, Using, Map, ConcatAll, Repeat, Zip, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, Generate, Keep, ContainerOperator, Pairwise, Reduce, Scan, SkipFirst, SomeSatisfy, TakeFirst, TakeLast, TakeWhile, ThrowIfEmpty } from './container.js';
import { Concat, FromArray, FromIterator, FromIterable, Using, Buffer, Map, ConcatAll, Repeat, Zip, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, Generate, Keep, ContainerOperator, Pairwise, Reduce, Scan, SkipFirst, SomeSatisfy, TakeFirst, TakeLast, TakeWhile, ThrowIfEmpty } from './container.js';
import { DisposableLike, DisposableOrTeardown } from './disposable.js';

@@ -180,2 +180,3 @@ import { DispatcherLike } from './dispatcher.js';

}): ObservableOperator<T, readonly T[]>;
declare const bufferT: Buffer<ObservableLike<unknown>>;

@@ -345,3 +346,3 @@ declare const map: <TA, TB>(mapper: Function1<TA, TB>) => ObservableOperator<TA, TB>;

readonly type: ObservableLike<this["T"]>;
readonly liftedStateType: Observer<this["T"]>;
readonly liftableStateType: Observer<this["T"]>;
readonly isEnumerable?: boolean;

@@ -363,2 +364,3 @@ sink(this: ObservableLike<T>, sink: Observer<T>): void;

readonly observerCount: number;
readonly replay: number;
}

@@ -421,2 +423,3 @@ /**

declare const observerCount: <T>(observable: MulticastObservableLike<T>) => number;
declare const replay: <T>(observable: MulticastObservableLike<T>) => number;
declare const pairwise: <T>() => ObservableOperator<T, [Option<T>, T]>;

@@ -502,2 +505,2 @@ declare const pairwiseT: Pairwise<ObservableLike<unknown>>;

export { AbstractDisposableObservable, AbstractObservable, AsyncReducer, MulticastObservableLike, ObservableEffectMode, ObservableLike, ObservableOperator, StreamLike, SubjectLike, ThrottleMode, __currentScheduler, __do, __memo, __observe, __using, buffer, catchError, combineLatest, combineLatestWith, concat, concatAll, concatAllT, concatT, createObservable, createSubject, createT, decodeWithCharset, decodeWithCharsetT, defer, distinctUntilChanged, distinctUntilChangedT, everySatisfy, everySatisfyT, exhaust, exhaustT, forkCombineLatest, forkMerge, forkZipLatest, fromArray, fromArrayT, fromDisposable, fromEnumerable, fromIterable, fromIterableT, fromIterator, fromIteratorT, fromPromise, generate, generateT, keep, keepT, map, mapAsync, mapT, merge, mergeAll, mergeAllT, mergeT, never, observable, observerCount, 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 };
export { AbstractDisposableObservable, AbstractObservable, AsyncReducer, MulticastObservableLike, ObservableEffectMode, ObservableLike, ObservableOperator, StreamLike, SubjectLike, ThrottleMode, __currentScheduler, __do, __memo, __observe, __using, buffer, bufferT, catchError, combineLatest, combineLatestWith, concat, concatAll, concatAllT, concatT, createObservable, createSubject, createT, decodeWithCharset, decodeWithCharsetT, defer, distinctUntilChanged, distinctUntilChangedT, everySatisfy, everySatisfyT, exhaust, exhaustT, forkCombineLatest, forkMerge, forkZipLatest, fromArray, fromArrayT, fromDisposable, fromEnumerable, fromIterable, fromIterableT, fromIterator, fromIteratorT, fromPromise, generate, generateT, keep, keepT, map, mapAsync, mapT, merge, mergeAll, mergeAllT, mergeT, never, observable, observerCount, onNotify, onSubscribe, pairwise, pairwiseT, publish, reduce, reduceT, repeat, repeatT, replay, 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 };

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

var scheduler = require('./scheduler.js');
var liftable = require('./liftable.js');
var observer = require('./observer.js');

@@ -23,2 +24,3 @@ var option = require('./option.js');

}
const isEnumerable = (obs) => { var _a; return (_a = obs.isEnumerable) !== null && _a !== void 0 ? _a : false; };

@@ -156,4 +158,3 @@ class CreateObservable extends AbstractObservable {

*/
const lift = (operator, isEnumerable = false) => source => {
var _a;
const lift = (operator, isEnumerableOperator = false) => source => {
const sourceSource = source instanceof LiftedObservable ? source.source : source;

@@ -163,11 +164,11 @@ const allFunctions = source instanceof LiftedObservable

: [operator];
isEnumerable = ((_a = source.isEnumerable) !== null && _a !== void 0 ? _a : false) && isEnumerable;
return new LiftedObservable(sourceSource, allFunctions, isEnumerable);
isEnumerableOperator = isEnumerable(source) && isEnumerableOperator;
return new LiftedObservable(sourceSource, allFunctions, isEnumerableOperator);
};
const liftT = {
variance: "contravariant",
variance: liftable.contraVariant,
lift,
};
const liftSynchronousT = {
variance: "contravariant",
variance: liftable.contraVariant,
lift: op => lift(op, true),

@@ -209,3 +210,3 @@ };

function onDispose$2() {
function onDispose$1() {
if (disposable.isDisposed(this.inner)) {

@@ -232,3 +233,3 @@ functions.pipe(this.delegate, disposable.dispose());

}
const operator = (delegate) => functions.pipe(new SwitchObserver(delegate), disposable.addTo(delegate), disposable.onComplete(onDispose$2));
const operator = (delegate) => functions.pipe(new SwitchObserver(delegate), disposable.addTo(delegate), disposable.onComplete(onDispose$1));
const switchAllInstance = lift(operator);

@@ -392,3 +393,3 @@ /**

}
}), subscribe(observer.scheduler), disposable.addTo(observer), disposable.onComplete(this.cleanup));
}), subscribe(scheduler$1), disposable.addTo(observer), disposable.onComplete(this.cleanup));
effect.observable = observable;

@@ -474,5 +475,3 @@ effect.subscription = subscription;

const ctx = assertCurrentContext();
return ctx instanceof ObservableContext
? ctx.observe(observable)
: functions.raise("__observe may only be called within an observable or concurrent computation");
return ctx.observe(observable);
};

@@ -485,3 +484,3 @@ const deferSideEffect = (f, ...args) => defer(() => observer => {

const ctx = assertCurrentContext();
const scheduler = __currentScheduler();
const scheduler = ctx.observer.scheduler;
const observable = ctx.memo(deferSideEffect, f, ...args);

@@ -497,8 +496,6 @@ const subscribeOnScheduler = ctx.memo(subscribe, scheduler);

const ctx = assertCurrentContext();
return ctx instanceof ObservableContext
? ctx.observer.scheduler
: functions.raise("__currentScheduler may only be called within an observable computation");
return ctx.observer.scheduler;
}
function onDispose$1() {
function onDispose() {
const { ctx } = this;

@@ -550,3 +547,3 @@ ctx.completedCount++;

for (const observable of observables) {
const innerObserver = functions.pipe(new LatestObserver(delegate, ctx, mode), disposable.addTo(delegate), disposable.onComplete(onDispose$1), source.sourceFrom(observable));
const innerObserver = functions.pipe(new LatestObserver(delegate, ctx, mode), disposable.addTo(delegate), disposable.onComplete(onDispose), source.sourceFrom(observable));
observers.push(innerObserver);

@@ -556,3 +553,3 @@ }

const observable = defer(factory);
observable.isEnumerable = functions.pipe(observables, readonlyArray.everySatisfy(obs => { var _a; return (_a = obs.isEnumerable) !== null && _a !== void 0 ? _a : false; }));
observable.isEnumerable = functions.pipe(observables, readonlyArray.everySatisfy(isEnumerable));
return observable;

@@ -600,3 +597,3 @@ };

});
observable.isEnumerable = functions.pipe(observables, readonlyArray.everySatisfy(obs => { var _a; return (_a = obs.isEnumerable) !== null && _a !== void 0 ? _a : false; }));
observable.isEnumerable = functions.pipe(observables, readonlyArray.everySatisfy(isEnumerable));
return observable;

@@ -633,3 +630,3 @@ }

*/
const fromEnumerable = (options) => enumerable$1 => functions.pipe(functions.defer(enumerable$1, enumerable.enumerate), fromEnumerator(options));
const fromEnumerable = (options) => enumerable$1 => functions.pipe(functions.pipeLazy(enumerable$1, enumerable.enumerate), fromEnumerator(options));

@@ -690,12 +687,2 @@ /**

function onDispose() {
const { buffer } = this;
this.buffer = [];
if (buffer.length === 0) {
functions.pipe(this.delegate, disposable.dispose());
}
else {
functions.pipe(buffer, container.fromValue(fromArrayT), source.sinkInto(this.delegate));
}
}
class BufferObserver extends observer.Observer {

@@ -743,9 +730,21 @@ constructor(delegate, durationFunction, maxBufferSize, durationSubscription) {

: delay;
const maxBufferSize = (_b = options.maxBufferSize) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER;
const maxBufferSize = Math.max((_b = options.maxBufferSize) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER, 1);
const operator = (delegate) => {
const durationSubscription = disposable.createSerialDisposable();
return functions.pipe(new BufferObserver(delegate, durationFunction, maxBufferSize, durationSubscription), disposable.add(durationSubscription), disposable.addTo(delegate), disposable.onComplete(onDispose));
return functions.pipe(new BufferObserver(delegate, durationFunction, maxBufferSize, durationSubscription), disposable.add(durationSubscription), disposable.addTo(delegate), disposable.onComplete(function onDispose() {
const { buffer } = this;
this.buffer = [];
if (buffer.length === 0) {
functions.pipe(this.delegate, disposable.dispose());
}
else {
functions.pipe(buffer, container.fromValue(fromArrayT), source.sinkInto(this.delegate));
}
}));
};
return lift(operator, delay === Number.MAX_SAFE_INTEGER);
}
const bufferT = {
buffer,
};

@@ -1130,8 +1129,7 @@ const subscribeNext = (observer) => {

const _zip = (...observables) => {
const isEnumerable = functions.pipe(observables, readonlyArray.everySatisfy(obs => { var _a; return (_a = obs.isEnumerable) !== null && _a !== void 0 ? _a : false; }));
const isEnumerableOperator = functions.pipe(observables, readonlyArray.everySatisfy(isEnumerable));
const zipObservable = createObservable(observer => {
var _a;
const count = observables.length;
if (isEnumerable) {
const zipped = using(functions.defer(observables, readonlyArray.map(enumerateObs)), (...enumerators) => functions.pipe(enumerators, enumerator.zip, functions.returns, fromEnumerator()));
if (isEnumerableOperator) {
const zipped = using(functions.pipeLazy(observables, readonlyArray.map(enumerateObs)), (...enumerators) => functions.pipe(enumerator.zip(...enumerators), functions.returns, fromEnumerator()));
zipped.isEnumerable = true;

@@ -1144,3 +1142,3 @@ functions.pipe(zipped, source.sinkInto(observer));

const next = observables[index];
if ((_a = next.isEnumerable) !== null && _a !== void 0 ? _a : false) {
if (isEnumerable(next)) {
const enumerator$1 = enumerateObs(next);

@@ -1165,3 +1163,3 @@ enumerator.move(enumerator$1);

});
zipObservable.isEnumerable = isEnumerable;
zipObservable.isEnumerable = isEnumerableOperator;
return zipObservable;

@@ -1299,2 +1297,3 @@ };

const observerCount = (observable) => observable.observerCount;
const replay = (observable) => observable.replay;
const pairwise = source.createPairwiseOperator(liftSynchronousT, class PairwiseObserver extends observer.Observer {

@@ -1351,3 +1350,3 @@ constructor(delegate) {

*/
const scanAsync = (scanner, initialValue) => observable => using(() => createSubject(), accFeedbackStream => functions.pipe(observable, zipWithLatestFrom(accFeedbackStream, (next, acc) => functions.pipe(scanner(acc, next), takeFirst())), switchAll(), onNotify(dispatcher.dispatchTo(accFeedbackStream)), onSubscribe(functions.defer(accFeedbackStream, dispatcher.dispatch(initialValue())))));
const scanAsync = (scanner, initialValue) => observable => using(() => createSubject(), accFeedbackStream => functions.pipe(observable, zipWithLatestFrom(accFeedbackStream, (next, acc) => functions.pipe(scanner(acc, next), takeFirst())), switchAll(), onNotify(dispatcher.dispatchTo(accFeedbackStream)), onSubscribe(functions.pipeLazy(accFeedbackStream, dispatcher.dispatch(initialValue())))));
/**

@@ -1483,2 +1482,3 @@ * Returns an `ObservableLike` backed by a shared refcounted subscription to the

exports.buffer = buffer;
exports.bufferT = bufferT;
exports.catchError = catchError;

@@ -1538,2 +1538,3 @@ exports.combineLatest = combineLatest;

exports.repeatT = repeatT;
exports.replay = replay;
exports.retry = retry;

@@ -1540,0 +1541,0 @@ exports.scan = scan;

@@ -17,3 +17,4 @@ /**

declare const isNone: <T>(option: Option<T>) => option is undefined;
declare const getOrDefault: <T>(v: T) => (option: Option<T>) => T;
export { Option, isNone, isSome, none };
export { Option, getOrDefault, isNone, isSome, none };

@@ -17,5 +17,7 @@ 'use strict';

const isNone = (option) => option === none;
const getOrDefault = (v) => (option) => isSome(option) ? option : v;
exports.getOrDefault = getOrDefault;
exports.isNone = isNone;
exports.isSome = isSome;
exports.none = none;
{
"name": "@reactive-js/core",
"version": "0.8.0",
"version": "0.8.1",
"keywords": [

@@ -45,3 +45,3 @@ "asynchronous",

},
"gitHead": "548954b7d8664d57e8473cbfeba0eabed4f86b89"
"gitHead": "b9a4fea548d076523680ea5f285f2a3f83322fc4"
}

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

const subscription = functions.pipe(observable$1, observable.onNotify(functions.compose(functions.returns, updateState)), observable.subscribe(scheduler), disposable.onError(updateError));
return functions.defer(
return functions.pipeLazy(
// If a scheduler is allocated, then dispose the new scheduler

@@ -82,3 +82,3 @@ // which will also dispose any subscriptions. Otherwise

const callbackNode = scheduler.unstable_scheduleCallback(priority, callback, delay > 0 ? { delay } : option.none);
const callbackNodeDisposable = functions.pipe(disposable.createDisposable(functions.defer(callbackNode, scheduler.unstable_cancelCallback)), disposable.addTo(continuation));
const callbackNodeDisposable = functions.pipe(disposable.createDisposable(functions.pipeLazy(callbackNode, scheduler.unstable_cancelCallback)), disposable.addTo(continuation));
}

@@ -85,0 +85,0 @@ }

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

import { ConcatAll, FromArray, FromArrayOptions, ContainerLike, Container, ContainerOf, Concat, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, Generate, Keep, Map, ContainerOperator, Pairwise, Reduce, Repeat, Scan, SkipFirst, SomeSatisfy, TakeFirst, TakeLast, TakeWhile, ThrowIfEmpty, Using } from './container.js';
import { ConcatAll, FromArray, FromArrayOptions, ContainerLike, Container, ContainerOf, Buffer, Concat, DecodeWithCharset, DistinctUntilChanged, EverySatisfy, Generate, Keep, Map, ContainerOperator, Pairwise, Reduce, Repeat, Scan, SkipFirst, SomeSatisfy, TakeFirst, TakeLast, TakeWhile, ThrowIfEmpty, Using } from './container.js';
import { DisposableOrTeardown } from './disposable.js';

@@ -26,12 +26,6 @@ import { SideEffect1, Function1, Equality, Predicate, Updater, Factory, Reducer } from './functions.js';

/**
* Accumulates all values emitted by `runnable` into an array.
*
*/
declare const toArray: <T>() => Function1<RunnableLike<T>, readonly T[]>;
interface RunnableLike<T> extends SourceLike {
readonly T: unknown;
readonly type: RunnableLike<this["T"]>;
readonly liftedStateType: RunnableSink<this["T"]>;
readonly liftableStateType: RunnableSink<this["T"]>;
sink(this: RunnableLike<T>, sink: RunnableSink<T>): void;

@@ -46,2 +40,6 @@ }

declare const type: RunnableLike<unknown>;
declare const buffer: <T>(options?: {
readonly maxBufferSize?: number;
}) => RunnableOperator<T, readonly T[]>;
declare const bufferT: Buffer<RunnableLike<unknown>>;
declare const catchError: <T>(onError: Function1<unknown, RunnableLike<T> | void>) => RunnableOperator<T, T>;

@@ -100,5 +98,9 @@ declare const concat: Concat<RunnableLike<unknown>>["concat"];

declare const throwIfEmptyT: ThrowIfEmpty<RunnableLike<unknown>>;
/**
* Accumulates all values emitted by `runnable` into an array.
*/
declare const toArray: <T>() => Function1<RunnableLike<T>, readonly T[]>;
declare const using: Using<RunnableLike<unknown>>["using"];
declare const usingT: Using<RunnableLike<unknown>>;
export { RunnableLike, RunnableOperator, ToRunnable, catchError, concat, concatAll, concatAllT, concatT, createRunnable, createT, decodeWithCharset, decodeWithCharsetT, distinctUntilChanged, distinctUntilChangedT, everySatisfy, everySatisfyT, first, forEach, fromArray, fromArrayT, generate, generateT, keep, keepT, last, map, mapT, never, onNotify, onSink, pairwise, pairwiseT, reduce, reduceT, repeat, repeatT, scan, scanT, skipFirst, skipFirstT, someSatisfy, someSatisfyT, takeFirst, takeFirstT, takeLast, takeLastT, takeWhile, takeWhileT, throwIfEmpty, throwIfEmptyT, toArray, toRunnable, type, using, usingT };
export { RunnableLike, RunnableOperator, ToRunnable, buffer, bufferT, catchError, concat, concatAll, concatAllT, concatT, createRunnable, createT, decodeWithCharset, decodeWithCharsetT, distinctUntilChanged, distinctUntilChangedT, everySatisfy, everySatisfyT, first, forEach, fromArray, fromArrayT, generate, generateT, keep, keepT, last, map, mapT, never, onNotify, onSink, pairwise, pairwiseT, reduce, reduceT, repeat, repeatT, scan, scanT, skipFirst, skipFirstT, someSatisfy, someSatisfyT, takeFirst, takeFirstT, takeLast, takeLastT, takeWhile, takeWhileT, throwIfEmpty, throwIfEmptyT, toArray, toRunnable, type, using, usingT };

@@ -8,4 +8,6 @@ 'use strict';

var option = require('./option.js');
var readonlyArray = require('./readonlyArray.js');
var source = require('./source.js');
var runnableSink = require('./runnableSink.js');
var liftable = require('./liftable.js');

@@ -23,2 +25,3 @@ class AbstractRunnable extends source.AbstractSource {

this._run(sink);
functions.pipe(sink, disposable.dispose());
}

@@ -35,2 +38,19 @@ catch (cause) {

const run = (f) => (runnable) => functions.pipe(f(), source.sourceFrom(runnable), disposable.dispose(), ({ error, result }) => option.isSome(error) ? functions.raise(error.cause) : result);
class FirstSink extends runnableSink.RunnableSink {
constructor() {
super(...arguments);
this.result = option.none;
}
notify(next) {
this.result = next;
functions.pipe(this, disposable.dispose());
}
}
const first = () => {
const createSink = () => new FirstSink();
return run(createSink);
};
const fromArray = (options = {}) => values => {

@@ -73,3 +93,3 @@ var _a, _b;

const liftT = {
variance: "contravariant",
variance: liftable.contraVariant,
lift,

@@ -88,3 +108,3 @@ };

}
const _concatAll = lift(delegate => functions.pipe(new FlattenSink(delegate), disposable.addTo(delegate)));
const _concatAll = lift(delegate => functions.pipe(new FlattenSink(delegate), disposable.bindTo(delegate)));
const concatAll = () => _concatAll;

@@ -95,19 +115,2 @@ const concatAllT = {

const run = (f) => (runnable) => functions.pipe(f(), source.sourceFrom(runnable), disposable.dispose(), ({ error, result }) => option.isSome(error) ? functions.raise(error.cause) : result);
class FirstSink extends runnableSink.RunnableSink {
constructor() {
super(...arguments);
this.result = option.none;
}
notify(next) {
this.result = next;
functions.pipe(this, disposable.dispose());
}
}
const first = () => {
const createSink = () => new FirstSink();
return run(createSink);
};
class ForEachSink extends runnableSink.RunnableSink {

@@ -139,20 +142,15 @@ constructor(notify) {

class ToArraySink extends runnableSink.RunnableSink {
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 buffer = source.createBufferOperator({ ...liftT, ...fromArrayT }, class BufferSink extends runnableSink.RunnableSink {
constructor(delegate, maxBufferSize) {
super();
this.delegate = delegate;
this.maxBufferSize = maxBufferSize;
this.buffer = [];
}
});
const bufferT = {
buffer,
};
const catchError = source.createCatchErrorOperator(liftT, class CatchErrorSink extends runnableSink.RunnableSink {

@@ -365,2 +363,6 @@ constructor(delegate) {

};
/**
* Accumulates all values emitted by `runnable` into an array.
*/
const toArray = () => functions.compose(buffer(), first(), option.getOrDefault(readonlyArray.empty));
const using = source.createUsing(createT);

@@ -371,2 +373,4 @@ const usingT = {

exports.buffer = buffer;
exports.bufferT = bufferT;
exports.catchError = catchError;

@@ -373,0 +377,0 @@ exports.concat = concat;

@@ -12,5 +12,6 @@ import { DisposableLike } from './disposable.js';

*/
declare const toPriorityScheduler: (hostScheduler: SchedulerLike) => PrioritySchedulerLike;
declare const toPausableScheduler: (hostScheduler: SchedulerLike) => PausableSchedulerLike;
declare const createPriorityScheduler: (hostScheduler: SchedulerLike) => PrioritySchedulerLike;
declare const createPausableScheduler: (hostScheduler: SchedulerLike) => PausableSchedulerLike;
declare const __yield: (options?: {

@@ -46,6 +47,3 @@ delay?: number;

interface SchedulerImplementation {
inContinuation: boolean;
}
declare const runContinuation: <TScheduler extends SchedulerImplementation>(continuation: SchedulerContinuationLike) => Function1<TScheduler, TScheduler>;
declare const runContinuation: <TScheduler extends SchedulerImplementationLike>(continuation: SchedulerContinuationLike) => Function1<TScheduler, TScheduler>;
declare const inContinuation: (scheduler: SchedulerLike | PrioritySchedulerLike) => boolean;

@@ -119,3 +117,6 @@ declare const now: (scheduler: SchedulerLike) => number;

}
interface SchedulerImplementationLike extends DisposableLike {
inContinuation: boolean;
}
export { PausableSchedulerLike, PrioritySchedulerLike, SchedulerContinuationLike, SchedulerImplementation, SchedulerLike, VirtualTimeSchedulerLike, __yield, createHostScheduler, createVirtualTimeScheduler, inContinuation, now, runContinuation, schedule, toPausableScheduler, toPriorityScheduler, toSchedulerWithPriority };
export { PausableSchedulerLike, PrioritySchedulerLike, SchedulerContinuationLike, SchedulerImplementationLike, SchedulerLike, VirtualTimeSchedulerLike, __yield, createHostScheduler, createPausableScheduler, createPriorityScheduler, createVirtualTimeScheduler, inContinuation, now, runContinuation, schedule, toSchedulerWithPriority };

@@ -157,10 +157,2 @@ 'use strict';

const move = (scheduler) => {
// First fast forward through any disposed tasks.
peek(scheduler);
const task = scheduler.queue.pop();
const hasCurrent = option.isSome(task);
scheduler.current = task;
return hasCurrent;
};
const peek = (scheduler) => {

@@ -196,8 +188,2 @@ const { delayed, queue } = scheduler;

};
const comparator$1 = (a, b) => {
let diff = 0;
diff = diff !== 0 ? diff : a.priority - b.priority;
diff = diff !== 0 ? diff : a.taskID - b.taskID;
return diff;
};
const delayedComparator = (a, b) => {

@@ -209,17 +195,13 @@ let diff = 0;

};
const scheduleContinuation = (scheduler, task) => {
const dueTime = task.dueTime;
const delay = Math.max(dueTime - now(scheduler), 0);
scheduler.dueTime = dueTime;
scheduler.inner = functions.pipe(scheduler.host, schedule(scheduler.continuation, { delay }));
};
function clearQueues() {
this.queue.clear();
this.delayed.clear();
}
class PriorityScheduler extends disposable.AbstractSerialDisposable {
class AbstractQueueScheduler extends enumerator.AbstractEnumerator {
constructor(host) {
super();
this.host = host;
this.continuation = () => {
this.delayed = createPriorityQueue(delayedComparator);
this.inContinuation = false;
this.dueTime = 0;
this.taskIDCounter = 0;
this.yieldRequested = false;
this._inner = disposable.disposed;
this.hostContinuation = () => {
for (let task = peek(this); option.isSome(task) && !disposable.isDisposed(this); task = peek(this)) {

@@ -229,3 +211,3 @@ const { continuation, dueTime } = task;

if (delay === 0) {
move(this);
enumerator.move(this);
functions.pipe(this, runContinuation(continuation));

@@ -239,11 +221,13 @@ }

};
this.current = option.none;
this.delayed = createPriorityQueue(delayedComparator);
this.dueTime = 0;
this.inContinuation = false;
this.isPaused = false;
this.queue = createPriorityQueue(comparator$1);
this.taskIDCounter = 0;
this.yieldRequested = false;
}
get inner() {
return this._inner;
}
set inner(newInner) {
const { _inner: oldInner } = this;
if (oldInner !== newInner) {
oldInner.dispose();
this._inner = newInner;
}
}
get now() {

@@ -253,9 +237,2 @@ return now(this.host);

get shouldYield() {
const { current } = this;
const next = peek(this);
const nextTaskIsHigherPriority = option.isSome(current) &&
option.isSome(next) &&
current !== next &&
next.dueTime <= now(this) &&
next.priority < current.priority;
const { inContinuation, yieldRequested } = this;

@@ -265,19 +242,20 @@ if (inContinuation) {

}
const next = peek(this);
return (inContinuation &&
(yieldRequested ||
disposable.isDisposed(this) ||
!enumerator.hasCurrent(this) ||
this.isPaused ||
nextTaskIsHigherPriority ||
(option.isSome(next) ? this._shouldYield(next) : false) ||
this.host.shouldYield));
}
pause() {
this.isPaused = true;
this.inner = disposable.disposed;
}
resume() {
const head = peek(this);
this.isPaused = false;
if (disposable.isDisposed(this.inner) && option.isSome(head)) {
scheduleContinuation(this, head);
move() {
enumerator.reset(this);
// First fast forward through any disposed tasks.
peek(this);
const task = this.queue.pop();
if (option.isSome(task)) {
this.current = task;
}
return enumerator.hasCurrent(this);
}

@@ -287,38 +265,61 @@ requestYield() {

}
scheduleOnHost() {
const task = peek(this);
const continuationActive = !disposable.isDisposed(this.inner) && option.isSome(task) && this.dueTime <= task.dueTime;
if (option.isNone(task) || continuationActive || this.isPaused) {
return;
}
const dueTime = task.dueTime;
const delay = Math.max(dueTime - now(this), 0);
this.dueTime = dueTime;
this.inner = functions.pipe(this.host, schedule(this.hostContinuation, { delay }));
}
schedule(continuation, options = {}) {
var _a;
const { delay = Math.max((_a = options.delay) !== null && _a !== void 0 ? _a : 0, 0) } = options;
let { priority } = options;
priority = option.isSome(priority)
? priority
: inContinuation(this)
? this.current.priority
: Number.MAX_SAFE_INTEGER;
functions.pipe(this, disposable.add(continuation, true));
if (!disposable.isDisposed(continuation)) {
const { current, now } = this;
const { now } = this;
const dueTime = Math.max(now + delay, now);
const task = inContinuation(this) &&
option.isSome(current) &&
current.continuation === continuation &&
enumerator.hasCurrent(this) &&
enumerator.current(this).continuation === continuation &&
delay <= 0
? current
: {
? enumerator.current(this)
: this.createTask({
taskID: this.taskIDCounter++,
continuation,
priority,
dueTime,
};
}, options);
const { delayed, queue } = this;
const targetQueue = dueTime > now ? delayed : queue;
targetQueue.push(task);
const head = peek(this);
const continuationActive = !disposable.isDisposed(this.inner) && this.dueTime <= dueTime;
if (head === task && !continuationActive && !this.isPaused) {
scheduleContinuation(this, head);
}
this.scheduleOnHost();
}
}
}
const createPriorityScheduler = (hostScheduler) => functions.pipe(new PriorityScheduler(hostScheduler), disposable.addTo(hostScheduler, true), disposable.onDisposed(clearQueues));
const comparator$2 = (a, b) => {
let diff = 0;
diff = diff !== 0 ? diff : a.priority - b.priority;
diff = diff !== 0 ? diff : a.taskID - b.taskID;
return diff;
};
class PriorityScheduler extends AbstractQueueScheduler {
constructor() {
super(...arguments);
this.isPaused = false;
this.queue = createPriorityQueue(comparator$2);
}
_shouldYield(next) {
const { current } = this;
return (current !== next &&
next.dueTime <= now(this) &&
next.priority > current.priority);
}
createTask(task, options) {
var _a;
return { ...task, priority: (_a = Number(options.delay)) !== null && _a !== void 0 ? _a : 0 };
}
}
/**

@@ -331,7 +332,41 @@ * Creates a new priority scheduler which schedules work using the provided

*/
const toPriorityScheduler = (hostScheduler) => {
return createPriorityScheduler(hostScheduler);
const createPriorityScheduler = (hostScheduler) => {
const scheduler = functions.pipe(new PriorityScheduler(hostScheduler), disposable.addTo(hostScheduler, true), disposable.onDisposed(() => {
scheduler.queue.clear();
scheduler.delayed.clear();
}));
return scheduler;
};
const toPausableScheduler = (hostScheduler) => {
const scheduler = createPriorityScheduler(hostScheduler);
const comparator$1 = (a, b) => {
let diff = 0;
diff = diff !== 0 ? diff : a.taskID - b.taskID;
return diff;
};
class PausableScheduler extends AbstractQueueScheduler {
constructor() {
super(...arguments);
this.isPaused = false;
this.queue = createPriorityQueue(comparator$1);
}
pause() {
this.isPaused = true;
this.inner = disposable.disposed;
}
resume() {
this.isPaused = false;
this.scheduleOnHost();
}
_shouldYield() {
return false;
}
createTask(task, _) {
return task;
}
}
const createPausableScheduler = (hostScheduler) => {
const scheduler = functions.pipe(new PausableScheduler(hostScheduler), disposable.addTo(hostScheduler, true), disposable.onDisposed(() => {
scheduler.queue.clear();
scheduler.delayed.clear();
}));
scheduler.pause();

@@ -562,2 +597,4 @@ return scheduler;

exports.createHostScheduler = createHostScheduler;
exports.createPausableScheduler = createPausableScheduler;
exports.createPriorityScheduler = createPriorityScheduler;
exports.createVirtualTimeScheduler = createVirtualTimeScheduler;

@@ -568,4 +605,2 @@ exports.inContinuation = inContinuation;

exports.schedule = schedule;
exports.toPausableScheduler = toPausableScheduler;
exports.toPriorityScheduler = toPriorityScheduler;
exports.toSchedulerWithPriority = toSchedulerWithPriority;

@@ -1,8 +0,8 @@

import { Container, ContainerOf, ContainerOperator, FromArray, FromArrayOptions } from './container.js';
import { Container, ContainerOf, FromArray, FromArrayOptions, ContainerOperator } from './container.js';
import { DisposableLike, DisposableOrTeardown } from './disposable.js';
import { Function1, SideEffect1, Equality, Predicate, Reducer, Factory } from './functions.js';
import { LiftedStateLike, LiftableLike, Lift as Lift$1, LiftedStateOf, AbstractLiftable, AbstractDisposableLiftable } from './liftable.js';
import { LiftableStateLike, LiftableLike, Lift as Lift$1, ContraVariant, LiftableStateOf, AbstractLiftable, AbstractDisposableLiftable, DelegatingLiftableStateOf } from './liftable.js';
import { Option } from './option.js';
interface SinkLike<T> extends LiftedStateLike {
interface SinkLike<T> extends LiftableStateLike {
assertState(this: SinkLike<T>): void;

@@ -20,9 +20,9 @@ /**

interface SourceLike extends LiftableLike {
readonly liftedStateType: SinkLike<unknown>;
sink(this: this["type"], sink: this["liftedStateType"]): void;
readonly liftableStateType: SinkLike<unknown>;
sink(this: this["type"], sink: this["liftableStateType"]): void;
}
interface Lift<C extends SourceLike> extends Lift$1<C, "contravariant"> {
interface Lift<C extends SourceLike> extends Lift$1<C, ContraVariant> {
}
interface CreateSource<C extends SourceLike> extends Container<C> {
create<T>(onSink: (sink: LiftedStateOf<C, T>) => void): ContainerOf<C, T>;
create<T>(onSink: (sink: LiftableStateOf<C, T>) => void): ContainerOf<C, T>;
}

@@ -35,15 +35,23 @@ declare abstract class AbstractSource<T, TSink extends SinkLike<T>> extends AbstractLiftable<TSink> implements SourceLike {

}
declare const notify: <C extends SourceLike, T, TSink extends LiftedStateOf<C, T>>(v: T) => Function1<TSink, TSink>;
declare const notifySink: <C extends SourceLike, T, TSink extends LiftedStateOf<C, T>>(sink: TSink) => SideEffect1<T>;
declare const sinkInto: <C extends SourceLike, T, TSink extends LiftedStateOf<C, T>>(sink: TSink) => Function1<C, C>;
declare const sourceFrom: <C extends SourceLike, T, TSink extends LiftedStateOf<C, T>>(source: C) => Function1<TSink, TSink>;
declare const createCatchErrorOperator: <C extends SourceLike>(m: Lift<C>, CatchErrorSink: new <T>(delegate: LiftedStateOf<C, T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
}) => <T_1>(f: Function1<unknown, void | ContainerOf<C, T_1>>) => ContainerOperator<C, T_1, T_1>;
declare const createDecodeWithCharsetOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, DecodeWithCharsetSink: new (delegate: LiftedStateOf<C, string>, textDecoder: TextDecoder) => LiftedStateOf<C, ArrayBuffer> & {
readonly delegate: LiftedStateOf<C, string>;
declare const notify: <C extends SourceLike, T, TSink extends LiftableStateOf<C, T>>(v: T) => Function1<TSink, TSink>;
declare const notifySink: <C extends SourceLike, T, TSink extends LiftableStateOf<C, T>>(sink: TSink) => SideEffect1<T>;
declare const sinkInto: <C extends SourceLike, T, TSink extends LiftableStateOf<C, T>>(sink: TSink) => Function1<C, C>;
declare const sourceFrom: <C extends SourceLike, T, TSink extends LiftableStateOf<C, T>>(source: C) => Function1<TSink, TSink>;
declare const createBufferOperator: <C extends SourceLike>(m: Lift<C> & FromArray<C, FromArrayOptions>, BufferSink: new <T>(delegate: LiftableStateOf<C, readonly T[]>, maxBufferSize: number) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, readonly T[]>;
} & {
buffer: T[];
readonly maxBufferSize: number;
}) => <T_1>(options?: {
readonly maxBufferSize?: number;
}) => ContainerOperator<C, T_1, readonly T_1[]>;
declare const createCatchErrorOperator: <C extends SourceLike>(m: Lift<C>, CatchErrorSink: new <T>(delegate: LiftableStateOf<C, T>) => DelegatingLiftableStateOf<C, T, T, LiftableStateOf<C, T>>) => <T_1>(f: Function1<unknown, void | ContainerOf<C, T_1>>) => ContainerOperator<C, T_1, T_1>;
declare const createDecodeWithCharsetOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, DecodeWithCharsetSink: new (delegate: LiftableStateOf<C, string>, textDecoder: TextDecoder) => LiftableStateOf<C, ArrayBuffer> & {
readonly delegate: LiftableStateOf<C, string>;
} & {
readonly textDecoder: TextDecoder;
}) => (charset?: string) => ContainerOperator<C, ArrayBuffer, string>;
declare const createDistinctUntilChangedOperator: <C extends SourceLike>(m: Lift<C>, DistinctUntilChangedSink: new <T>(delegate: LiftedStateOf<C, T>, equality: Equality<T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createDistinctUntilChangedOperator: <C extends SourceLike>(m: Lift<C>, DistinctUntilChangedSink: new <T>(delegate: LiftableStateOf<C, T>, equality: Equality<T>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
readonly equality: Equality<T>;

@@ -55,34 +63,41 @@ prev: Option<T>;

} | undefined) => ContainerOperator<C, T_1, T_1>;
declare const createEverySatisfyOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, EverySatisfySink: new <T>(delegate: LiftedStateOf<C, boolean>, predicate: Predicate<T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, boolean>;
declare const createEverySatisfyOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, EverySatisfySink: new <T>(delegate: LiftableStateOf<C, boolean>, predicate: Predicate<T>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, boolean>;
} & {
readonly predicate: Predicate<T>;
}) => <T_1>(predicate: Predicate<T_1>) => ContainerOperator<C, T_1, boolean>;
declare const createKeepOperator: <C extends SourceLike>(m: Lift<C>, KeepSink: new <T>(delegate: LiftedStateOf<C, T>, predicate: Predicate<T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createKeepOperator: <C extends SourceLike>(m: Lift<C>, KeepSink: new <T>(delegate: LiftableStateOf<C, T>, predicate: Predicate<T>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
readonly predicate: Predicate<T>;
}) => <T_1>(predicate: Predicate<T_1>) => ContainerOperator<C, T_1, T_1>;
declare const createMapOperator: <C extends SourceLike>(m: Lift<C>, MapSink: new <TA, TB>(delegate: LiftedStateOf<C, TB>, mapper: Function1<TA, TB>) => LiftedStateOf<C, TA> & {
readonly delegate: LiftedStateOf<C, TB>;
declare const createMapOperator: <C extends SourceLike>(m: Lift<C>, MapSink: new <TA, TB>(delegate: LiftableStateOf<C, TB>, mapper: Function1<TA, TB>) => LiftableStateOf<C, TA> & {
readonly delegate: LiftableStateOf<C, TB>;
} & {
readonly mapper: Function1<TA, TB>;
}) => <TA_1, TB_1>(mapper: Function1<TA_1, TB_1>) => ContainerOperator<C, TA_1, TB_1>;
declare const createOnNotifyOperator: <C extends SourceLike>(m: Lift<C>, OnNotifySink: new <T>(delegate: LiftedStateOf<C, T>, onNotify: SideEffect1<T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createOnNotifyOperator: <C extends SourceLike>(m: Lift<C>, OnNotifySink: new <T>(delegate: LiftableStateOf<C, T>, onNotify: SideEffect1<T>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
readonly onNotify: SideEffect1<T>;
}) => <T_1>(onNotify: SideEffect1<T_1>) => ContainerOperator<C, T_1, T_1>;
declare const createPairwiseOperator: <C extends SourceLike>(m: Lift<C>, PairwiseSink: new <T>(delegate: LiftedStateOf<C, [Option<T>, T]>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, [Option<T>, T]>;
declare const createPairwiseOperator: <C extends SourceLike>(m: Lift<C>, PairwiseSink: new <T>(delegate: LiftableStateOf<C, [Option<T>, T]>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, [Option<T>, T]>;
} & {
prev: Option<T>;
hasPrev: boolean;
}) => <T_1>() => ContainerOperator<C, T_1, [Option<T_1>, T_1]>;
declare const createReduceOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, ReduceSink: new <T, TAcc>(delegate: LiftedStateOf<C, TAcc>, reducer: Reducer<T, TAcc>, acc: TAcc) => LiftedStateOf<C, T> & {
declare const createReduceOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, ReduceSink: new <T, TAcc>(delegate: LiftableStateOf<C, TAcc>, reducer: Reducer<T, TAcc>, acc: TAcc) => LiftableStateOf<C, T> & {
readonly reducer: Reducer<T, TAcc>;
acc: TAcc;
}) => <T_1, TAcc_1>(reducer: Reducer<T_1, TAcc_1>, initialValue: Factory<TAcc_1>) => ContainerOperator<C, T_1, TAcc_1>;
declare const createScanOperator: <C extends SourceLike>(m: Lift<C>, ScanSink: new <T, TAcc>(delegate: LiftedStateOf<C, TAcc>, reducer: Reducer<T, TAcc>, acc: TAcc) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, TAcc>;
declare const createScanOperator: <C extends SourceLike>(m: Lift<C>, ScanSink: new <T, TAcc>(delegate: LiftableStateOf<C, TAcc>, reducer: Reducer<T, TAcc>, acc: TAcc) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, TAcc>;
} & {
readonly reducer: Reducer<T, TAcc>;
acc: TAcc;
}) => <T_1, TAcc_1>(reducer: Reducer<T_1, TAcc_1>, initialValue: Factory<TAcc_1>) => ContainerOperator<C, T_1, TAcc_1>;
declare const createSkipFirstOperator: <C extends SourceLike>(m: Lift<C>, SkipFirstSink: new <T>(delegate: LiftedStateOf<C, T>, skipCount: number) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createSkipFirstOperator: <C extends SourceLike>(m: Lift<C>, SkipFirstSink: new <T>(delegate: LiftableStateOf<C, T>, skipCount: number) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
count: number;

@@ -93,8 +108,10 @@ readonly skipCount: number;

}) => ContainerOperator<C, T_1, T_1>;
declare const createSomeSatisfyOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, SomeSatisfySink: new <T>(delegate: LiftedStateOf<C, boolean>, predicate: Predicate<T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, boolean>;
declare const createSomeSatisfyOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, SomeSatisfySink: new <T>(delegate: LiftableStateOf<C, boolean>, predicate: Predicate<T>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, boolean>;
} & {
readonly predicate: Predicate<T>;
}) => <T_1>(predicate: Predicate<T_1>) => ContainerOperator<C, T_1, boolean>;
declare const createTakeFirstOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, TakeFirstSink: new <T>(delegate: LiftedStateOf<C, T>, maxCount: number) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createTakeFirstOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, TakeFirstSink: new <T>(delegate: LiftableStateOf<C, T>, maxCount: number) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
count: number;

@@ -105,3 +122,3 @@ readonly maxCount: number;

}) => ContainerOperator<C, T_1, T_1>;
declare const createTakeLastOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, TakeLastSink: new <T>(delegate: LiftedStateOf<C, T>, maxCount: number) => LiftedStateOf<C, T> & {
declare const createTakeLastOperator: <C extends SourceLike>(m: FromArray<C, FromArrayOptions> & Lift<C>, TakeLastSink: new <T>(delegate: LiftableStateOf<C, T>, maxCount: number) => LiftableStateOf<C, T> & {
readonly last: T[];

@@ -112,4 +129,5 @@ readonly maxCount: number;

}) => ContainerOperator<C, T_1, T_1>;
declare const createTakeWhileOperator: <C extends SourceLike>(m: Lift<C>, TakeWhileSink: new <T>(delegate: LiftedStateOf<C, T>, predicate: Predicate<T>, inclusive: boolean) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createTakeWhileOperator: <C extends SourceLike>(m: Lift<C>, TakeWhileSink: new <T>(delegate: LiftableStateOf<C, T>, predicate: Predicate<T>, inclusive: boolean) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
readonly predicate: Predicate<T>;

@@ -120,4 +138,5 @@ readonly inclusive: boolean;

}) => ContainerOperator<C, T_1, T_1>;
declare const createThrowIfEmptyOperator: <C extends SourceLike>(m: Lift<C>, ThrowIfEmptySink: new <T>(delegate: LiftedStateOf<C, T>) => LiftedStateOf<C, T> & {
readonly delegate: LiftedStateOf<C, T>;
declare const createThrowIfEmptyOperator: <C extends SourceLike>(m: Lift<C>, ThrowIfEmptySink: new <T>(delegate: LiftableStateOf<C, T>) => LiftableStateOf<C, T> & {
readonly delegate: LiftableStateOf<C, T>;
} & {
isEmpty: boolean;

@@ -130,2 +149,2 @@ }) => <T_1>(factory: Factory<unknown>) => ContainerOperator<C, T_1, T_1>;

export { AbstractDisposableSource, AbstractSource, CreateSource, Lift, SinkLike, SourceLike, createCatchErrorOperator, createDecodeWithCharsetOperator, createDistinctUntilChangedOperator, createEverySatisfyOperator, createFromDisposable, createKeepOperator, createMapOperator, createNever, createOnNotifyOperator, createOnSink, createPairwiseOperator, createReduceOperator, createScanOperator, createSkipFirstOperator, createSomeSatisfyOperator, createTakeFirstOperator, createTakeLastOperator, createTakeWhileOperator, createThrowIfEmptyOperator, createUsing, notify, notifySink, sinkInto, sourceFrom };
export { AbstractDisposableSource, AbstractSource, CreateSource, Lift, SinkLike, SourceLike, createBufferOperator, createCatchErrorOperator, createDecodeWithCharsetOperator, createDistinctUntilChangedOperator, createEverySatisfyOperator, createFromDisposable, createKeepOperator, createMapOperator, createNever, createOnNotifyOperator, createOnSink, createPairwiseOperator, createReduceOperator, createScanOperator, createSkipFirstOperator, createSomeSatisfyOperator, createTakeFirstOperator, createTakeLastOperator, createTakeWhileOperator, createThrowIfEmptyOperator, createUsing, notify, notifySink, sinkInto, sourceFrom };

@@ -30,5 +30,31 @@ 'use strict';

};
const createBufferOperator = (m, BufferSink) => {
BufferSink.prototype.notify = function notifyBuffer(next) {
this.assertState();
const { buffer, maxBufferSize } = this;
buffer.push(next);
if (buffer.length === maxBufferSize) {
const buffer = this.buffer;
this.buffer = [];
this.delegate.notify(buffer);
}
};
return (options = {}) => {
var _a;
const maxBufferSize = Math.max((_a = options.maxBufferSize) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER, 1);
return functions.pipe((delegate) => functions.pipe(new BufferSink(delegate, maxBufferSize), disposable.addTo(delegate), disposable.onComplete(function onDispose() {
const { buffer } = this;
this.buffer = [];
if (buffer.length === 0) {
functions.pipe(this.delegate, disposable.dispose());
}
else {
functions.pipe(buffer, container.fromValue(m), sinkInto(this.delegate));
}
})), liftable.lift(m));
};
};
const createCatchErrorOperator = (m, CatchErrorSink) => (f) => {
CatchErrorSink.prototype.notify = function notifyDelegate(next) {
this.delegate.notify(next);
liftable.delegate(this).notify(next);
};

@@ -54,3 +80,3 @@ return functions.pipe((delegate) => functions.pipe(new CatchErrorSink(delegate), disposable.addTo(delegate, true), disposable.onComplete(() => functions.pipe(delegate, disposable.dispose())), disposable.onError(e => {

if (data.length > 0) {
this.delegate.notify(data);
liftable.delegate(this).notify(data);
}

@@ -79,6 +105,6 @@ };

this.hasValue = true;
this.delegate.notify(next);
liftable.delegate(this).notify(next);
}
};
return liftable.createDistinctUntilChangedLiftedOperator(m, DistinctUntilChangedSink);
return liftable.createDistinctUntilChangedLiftOperator(m, DistinctUntilChangedSink);
};

@@ -104,6 +130,6 @@ const createSatisfyOperator = (m, SatisfySink, defaultResult) => {

if (this.predicate(next)) {
this.delegate.notify(next);
liftable.delegate(this).notify(next);
}
};
return liftable.createKeepLiftedOperator(m, KeepSink);
return liftable.createKeepLiftOperator(m, KeepSink);
};

@@ -114,5 +140,5 @@ const createMapOperator = (m, MapSink) => {

const mapped = this.mapper(next);
this.delegate.notify(mapped);
liftable.delegate(this).notify(mapped);
};
return liftable.createMapLiftedOperator(m, MapSink);
return liftable.createMapLiftOperator(m, MapSink);
};

@@ -123,5 +149,5 @@ const createOnNotifyOperator = (m, OnNotifySink) => {

this.onNotify(next);
this.delegate.notify(next);
liftable.delegate(this).notify(next);
};
return liftable.createOnNotifyLiftedOperator(m, OnNotifySink);
return liftable.createOnNotifyLiftOperator(m, OnNotifySink);
};

@@ -134,5 +160,5 @@ const createPairwiseOperator = (m, PairwiseSink) => {

this.prev = value;
this.delegate.notify([prev, value]);
liftable.delegate(this).notify([prev, value]);
};
return liftable.createPairwiseLiftedOperator(m, PairwiseSink);
return liftable.createPairwiseLiftOperator(m, PairwiseSink);
};

@@ -156,5 +182,5 @@ const createReduceOperator = (m, ReduceSink) => {

this.acc = nextAcc;
this.delegate.notify(nextAcc);
liftable.delegate(this).notify(nextAcc);
};
return liftable.createScanLiftedOperator(m, ScanSink);
return liftable.createScanLiftOperator(m, ScanSink);
};

@@ -165,6 +191,6 @@ const createSkipFirstOperator = (m, SkipFirstSink) => {

if (this.count > this.skipCount) {
this.delegate.notify(next);
liftable.delegate(this).notify(next);
}
};
return liftable.createSkipFirstLiftedOperator(m, SkipFirstSink);
return liftable.createSkipFirstLiftOperator(m, SkipFirstSink);
};

@@ -176,3 +202,3 @@ const createSomeSatisfyOperator = (m, SomeSatisfySink) => createSatisfyOperator(m, SomeSatisfySink, false);

this.count++;
this.delegate.notify(next);
liftable.delegate(this).notify(next);
if (this.count >= this.maxCount) {

@@ -182,3 +208,3 @@ functions.pipe(this, disposable.dispose());

};
return liftable.createTakeFirstLiftedOperator(m, TakeFirstSink);
return liftable.createTakeFirstLiftOperator(m, TakeFirstSink);
};

@@ -212,3 +238,3 @@ const createTakeLastOperator = (m, TakeLastSink) => {

if (satisfiesPredicate || this.inclusive) {
this.delegate.notify(next);
liftable.delegate(this).notify(next);
}

@@ -219,3 +245,3 @@ if (!satisfiesPredicate) {

};
return liftable.createTakeWhileLiftedOperator(m, TakeWhileSink);
return liftable.createTakeWhileLiftOperator(m, TakeWhileSink);
};

@@ -226,5 +252,5 @@ const createThrowIfEmptyOperator = (m, ThrowIfEmptySink) => {

this.isEmpty = false;
this.delegate.notify(next);
liftable.delegate(this).notify(next);
};
return liftable.createThrowIfEmptyLiftedOperator(m, ThrowIfEmptySink);
return liftable.createThrowIfEmptyLiftOperator(m, ThrowIfEmptySink);
};

@@ -249,2 +275,3 @@ const createFromDisposable = (m) => (disposable$1) => functions.pipe(disposable$1, disposable.addTo, create(m));

exports.AbstractSource = AbstractSource;
exports.createBufferOperator = createBufferOperator;
exports.createCatchErrorOperator = createCatchErrorOperator;

@@ -251,0 +278,0 @@ exports.createDecodeWithCharsetOperator = createDecodeWithCharsetOperator;

@@ -63,3 +63,2 @@ import { EnumerableLike } from './enumerable.js';

}
declare type StreamableOperator<TSrcReq, TSrc, TReq, T> = Function1<StreamableLike<TSrcReq, TSrc, StreamLike<TSrcReq, TSrc>>, StreamableLike<TReq, T, StreamLike<TReq, T>>>;
declare type FlowMode = "resume" | "pause";

@@ -140,2 +139,2 @@ interface FlowableLike<T> extends StreamableLike<FlowMode, T, FlowableStreamLike<T>> {

export { AsyncEnumerableLike, AsyncEnumeratorLike, ConsumeContinue, ConsumeDone, FlowMode, FlowableLike, FlowableSinkLike, FlowableSinkStreamLike, FlowableStreamLike, StateStreamLike, StreamableLike, StreamableOperator, StreamableStateLike, __stream, consume, consumeAsync, consumeContinue, consumeDone, createActionReducer, createFlowableSinkAccumulator, createLiftedStreamable, createStateStore, createStreamble, empty, flow, fromArray, fromEnumerable, fromIterable, generate, identity, sinkInto, stream };
export { AsyncEnumerableLike, AsyncEnumeratorLike, ConsumeContinue, ConsumeDone, FlowMode, FlowableLike, FlowableSinkLike, FlowableSinkStreamLike, FlowableStreamLike, StateStreamLike, StreamableLike, StreamableStateLike, __stream, consume, consumeAsync, consumeContinue, consumeDone, createActionReducer, createFlowableSinkAccumulator, createLiftedStreamable, createStateStore, createStreamble, empty, flow, fromArray, fromEnumerable, fromIterable, generate, identity, sinkInto, stream };

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

}
get replay() {
return observable.replay(this.observable);
}
dispatch(req) {

@@ -66,2 +69,5 @@ functions.pipe(this.dispatcher, dispatcher.dispatch(req));

}
get replay() {
return observable.replay(this.subject);
}
sink(observer) {

@@ -152,3 +158,3 @@ functions.pipe(this.subject, source.sinkInto(observer));

*/
const createStateStore = (initialState, options) => createActionReducer(functions.updaterReducer, initialState, options);
const createStateStore = (initialState, options) => createActionReducer(functions.updateReducer, initialState, options);
const _empty = createLiftedStreamable(observable.takeFirst({ count: 0 }));

@@ -161,3 +167,3 @@ /**

const flow = ({ scheduler: scheduler$1, } = {}) => observable$1 => createLiftedStreamable((modeObs) => observable.createObservable(observer => {
const pausableScheduler = scheduler.toPausableScheduler(scheduler$1 !== null && scheduler$1 !== void 0 ? scheduler$1 : observer.scheduler);
const pausableScheduler = scheduler.createPausableScheduler(scheduler$1 !== null && scheduler$1 !== void 0 ? scheduler$1 : observer.scheduler);
functions.pipe(observer, source.sourceFrom(functions.pipe(observable$1, observable.subscribeOn(pausableScheduler), functions.pipe(pausableScheduler, observable.fromDisposable, observable.takeUntil))), disposable.add(functions.pipe(modeObs, observable.onNotify((mode) => {

@@ -164,0 +170,0 @@ switch (mode) {

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

}
get replay() {
return observable.replay(this.stateStream);
}
dispatch(stateOrUpdater, { replace } = { replace: false }) {

@@ -93,0 +96,0 @@ functions.pipe(({ uri: stateURI }) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc