Socket
Socket
Sign inDemoInstall

rxjs

Package Overview
Dependencies
0
Maintainers
3
Versions
165
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.0-alpha.9 to 8.0.0-alpha.10

dist/cjs/internal/util/rx.js

3

ajax/package.json

@@ -5,5 +5,4 @@ {

"main": "../dist/cjs/ajax/index.js",
"module": "../dist/esm5/ajax/index.js",
"es2015": "../dist/esm/ajax/index.js",
"module": "../dist/esm/ajax/index.js",
"sideEffects": false
}

@@ -17,6 +17,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.using = exports.timer = exports.throwError = exports.range = exports.race = exports.partition = exports.onErrorResumeNext = exports.of = exports.merge = exports.interval = exports.iif = exports.generate = exports.fromEventPattern = exports.fromEvent = exports.from = exports.forkJoin = exports.defer = exports.connectable = exports.concat = exports.combineLatest = exports.bindNodeCallback = exports.bindCallback = exports.UnsubscriptionError = exports.TimeoutError = exports.SequenceError = exports.NotFoundError = exports.EmptyError = exports.ArgumentOutOfRangeError = exports.firstValueFrom = exports.lastValueFrom = exports.isObservable = exports.identity = exports.noop = exports.pipe = exports.Subscriber = exports.Subscription = exports.Scheduler = exports.VirtualAction = exports.VirtualTimeScheduler = exports.animationFrameScheduler = exports.queueScheduler = exports.asyncScheduler = exports.asapScheduler = exports.AsyncSubject = exports.ReplaySubject = exports.BehaviorSubject = exports.Subject = exports.animationFrames = exports.observable = exports.Observable = void 0;
exports.mergeAll = exports.max = exports.materialize = exports.mapTo = exports.map = exports.last = exports.isEmpty = exports.ignoreElements = exports.groupBy = exports.first = exports.findIndex = exports.find = exports.finalize = exports.filter = exports.expand = exports.exhaustMap = exports.exhaustAll = exports.every = exports.endWith = exports.elementAt = exports.distinctUntilKeyChanged = exports.distinctUntilChanged = exports.distinct = exports.dematerialize = exports.delayWhen = exports.delay = exports.defaultIfEmpty = exports.debounceTime = exports.debounce = exports.count = exports.connect = exports.concatWith = exports.concatMapTo = exports.concatMap = exports.concatAll = exports.combineLatestWith = exports.combineLatestAll = exports.catchError = exports.bufferWhen = exports.bufferToggle = exports.bufferTime = exports.bufferCount = exports.buffer = exports.auditTime = exports.audit = exports.config = exports.NEVER = exports.EMPTY = exports.scheduled = exports.zip = void 0;
exports.withLatestFrom = exports.windowWhen = exports.windowToggle = exports.windowTime = exports.windowCount = exports.window = exports.toArray = exports.timestamp = exports.timeoutWith = exports.timeout = exports.timeInterval = exports.throwIfEmpty = exports.throttleTime = exports.throttle = exports.tap = exports.takeWhile = exports.takeUntil = exports.takeLast = exports.take = exports.switchScan = exports.switchMapTo = exports.switchMap = exports.switchAll = exports.subscribeOn = exports.startWith = exports.skipWhile = exports.skipUntil = exports.skipLast = exports.skip = exports.single = exports.shareReplay = exports.share = exports.sequenceEqual = exports.scan = exports.sampleTime = exports.sample = exports.retryWhen = exports.retry = exports.repeatWhen = exports.repeat = exports.reduce = exports.raceWith = exports.pairwise = exports.onErrorResumeNextWith = exports.observeOn = exports.min = exports.mergeWith = exports.mergeScan = exports.mergeMapTo = exports.mergeMap = void 0;
exports.zipWith = exports.zipAll = void 0;
exports.throwError = exports.range = exports.race = exports.partition = exports.onErrorResumeNext = exports.of = exports.merge = exports.interval = exports.iif = exports.generate = exports.fromEventPattern = exports.fromEvent = exports.from = exports.forkJoin = exports.defer = exports.connectable = exports.concat = exports.combineLatest = exports.bindNodeCallback = exports.bindCallback = exports.UnsubscriptionError = exports.TimeoutError = exports.SequenceError = exports.NotFoundError = exports.EmptyError = exports.ArgumentOutOfRangeError = exports.firstValueFrom = exports.lastValueFrom = exports.operate = exports.isObservable = exports.identity = exports.noop = exports.pipe = exports.rx = exports.Subscriber = exports.Subscription = exports.Scheduler = exports.VirtualAction = exports.VirtualTimeScheduler = exports.animationFrameScheduler = exports.queueScheduler = exports.asyncScheduler = exports.asapScheduler = exports.AsyncSubject = exports.ReplaySubject = exports.BehaviorSubject = exports.Subject = exports.animationFrames = exports.observable = exports.Observable = void 0;
exports.materialize = exports.mapTo = exports.map = exports.last = exports.isEmpty = exports.ignoreElements = exports.groupBy = exports.first = exports.findIndex = exports.find = exports.finalize = exports.filter = exports.expand = exports.exhaustMap = exports.exhaustAll = exports.every = exports.endWith = exports.elementAt = exports.distinctUntilKeyChanged = exports.distinctUntilChanged = exports.distinct = exports.dematerialize = exports.delayWhen = exports.delay = exports.defaultIfEmpty = exports.debounceTime = exports.debounce = exports.count = exports.connect = exports.concatWith = exports.concatMapTo = exports.concatMap = exports.concatAll = exports.combineLatestWith = exports.combineLatestAll = exports.catchError = exports.bufferWhen = exports.bufferToggle = exports.bufferTime = exports.bufferCount = exports.buffer = exports.auditTime = exports.audit = exports.config = exports.NEVER = exports.EMPTY = exports.scheduled = exports.zip = exports.using = exports.timer = void 0;
exports.windowToggle = exports.windowTime = exports.windowCount = exports.window = exports.toArray = exports.timestamp = exports.timeoutWith = exports.timeout = exports.timeInterval = exports.throwIfEmpty = exports.throttleTime = exports.throttle = exports.tap = exports.takeWhile = exports.takeUntil = exports.takeLast = exports.take = exports.switchScan = exports.switchMapTo = exports.switchMap = exports.switchAll = exports.subscribeOn = exports.startWith = exports.skipWhile = exports.skipUntil = exports.skipLast = exports.skip = exports.single = exports.shareReplay = exports.share = exports.sequenceEqual = exports.scan = exports.sampleTime = exports.sample = exports.retryWhen = exports.retry = exports.repeatWhen = exports.repeat = exports.reduce = exports.raceWith = exports.pairwise = exports.onErrorResumeNextWith = exports.observeOn = exports.min = exports.mergeWith = exports.mergeScan = exports.mergeMapTo = exports.mergeMap = exports.mergeAll = exports.max = void 0;
exports.zipWith = exports.zipAll = exports.withLatestFrom = exports.windowWhen = void 0;
var Observable_1 = require("./internal/Observable");

@@ -53,2 +53,4 @@ Object.defineProperty(exports, "Observable", { enumerable: true, get: function () { return Observable_1.Observable; } });

Object.defineProperty(exports, "Subscriber", { enumerable: true, get: function () { return Subscriber_1.Subscriber; } });
var rx_1 = require("./internal/util/rx");
Object.defineProperty(exports, "rx", { enumerable: true, get: function () { return rx_1.rx; } });
var pipe_1 = require("./internal/util/pipe");

@@ -62,2 +64,4 @@ Object.defineProperty(exports, "pipe", { enumerable: true, get: function () { return pipe_1.pipe; } });

Object.defineProperty(exports, "isObservable", { enumerable: true, get: function () { return isObservable_1.isObservable; } });
var Subscriber_2 = require("./internal/Subscriber");
Object.defineProperty(exports, "operate", { enumerable: true, get: function () { return Subscriber_2.operate; } });
var lastValueFrom_1 = require("./internal/lastValueFrom");

@@ -64,0 +68,0 @@ Object.defineProperty(exports, "lastValueFrom", { enumerable: true, get: function () { return lastValueFrom_1.lastValueFrom; } });

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AjaxTimeoutError = exports.AjaxError = void 0;
var createErrorClass_1 = require("../util/createErrorClass");
exports.AjaxError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function AjaxErrorImpl(message, xhr, request) {
this.message = message;
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType;
this.response = xhr.response;
};
});
exports.AjaxTimeoutError = (function () {
function AjaxTimeoutErrorImpl(xhr, request) {
exports.AjaxError.call(this, 'ajax timeout', xhr, request);
this.name = 'AjaxTimeoutError';
return this;
var AjaxError = (function (_super) {
__extends(AjaxError, _super);
function AjaxError(message, xhr, request) {
var _this = _super.call(this, message) || this;
_this.name = 'AjaxError';
_this.xhr = xhr;
_this.request = request;
_this.status = xhr.status;
_this.responseType = xhr.responseType;
_this.response = xhr.response;
return _this;
}
AjaxTimeoutErrorImpl.prototype = Object.create(exports.AjaxError.prototype);
return AjaxTimeoutErrorImpl;
})();
return AjaxError;
}(Error));
exports.AjaxError = AjaxError;
var AjaxTimeoutError = (function (_super) {
__extends(AjaxTimeoutError, _super);
function AjaxTimeoutError(xhr, request) {
var _this = _super.call(this, 'ajax timeout', xhr, request) || this;
_this.name = 'AjaxTimeoutError';
return _this;
}
return AjaxTimeoutError;
}(AjaxError));
exports.AjaxTimeoutError = AjaxTimeoutError;
//# sourceMappingURL=errors.js.map

@@ -31,5 +31,5 @@ "use strict";

var argsArgArrayOrObject_1 = require("../util/argsArgArrayOrObject");
var Subscriber_1 = require("../Subscriber");
var identity_1 = require("../util/identity");
var createObject_1 = require("../util/createObject");
var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
var empty_1 = require("./empty");

@@ -55,3 +55,3 @@ var from_1 = require("./from");

if (valueTransform === void 0) { valueTransform = identity_1.identity; }
return function (subscriber) {
return function (destination) {
var length = observables.length;

@@ -64,15 +64,19 @@ var values = new Array(length);

var hasFirstValue = false;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
values[i] = value;
if (!hasFirstValue) {
hasFirstValue = true;
remainingFirstValues--;
}
if (!remainingFirstValues) {
subscriber.next(valueTransform(Array.from(values)));
}
}, function () {
if (!--active) {
subscriber.complete();
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
values[i] = value;
if (!hasFirstValue) {
hasFirstValue = true;
remainingFirstValues--;
}
if (!remainingFirstValues) {
destination.next(valueTransform(Array.from(values)));
}
},
complete: function () {
if (!--active) {
destination.complete();
}
},
}));

@@ -79,0 +83,0 @@ };

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

exports.fromFetch = void 0;
var OperatorSubscriber_1 = require("../../operators/OperatorSubscriber");
var Subscriber_1 = require("../../Subscriber");
var Observable_1 = require("../../Observable");

@@ -33,3 +33,3 @@ var from_1 = require("../from");

var selector = initWithSelector.selector, init = __rest(initWithSelector, ["selector"]);
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var controller = new AbortController();

@@ -50,3 +50,3 @@ var signal = controller.signal;

outerSignal.addEventListener('abort', outerSignalHandler_1);
subscriber.add(function () { return outerSignal.removeEventListener('abort', outerSignalHandler_1); });
destination.add(function () { return outerSignal.removeEventListener('abort', outerSignalHandler_1); });
}

@@ -57,3 +57,3 @@ }

abortable = false;
subscriber.error(err);
destination.error(err);
};

@@ -63,11 +63,15 @@ fetch(input, perSubscriberInit)

if (selector) {
(0, from_1.from)(selector(response)).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, function () {
abortable = false;
subscriber.complete();
}, handleError));
(0, from_1.from)(selector(response)).subscribe((0, Subscriber_1.operate)({
destination: destination,
complete: function () {
abortable = false;
destination.complete();
},
error: handleError,
}));
}
else {
abortable = false;
subscriber.next(response);
subscriber.complete();
destination.next(response);
destination.complete();
}

@@ -74,0 +78,0 @@ })

@@ -8,5 +8,6 @@ "use strict";

var args_1 = require("../util/args");
var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var mapOneOrManyArgs_1 = require("../util/mapOneOrManyArgs");
var createObject_1 = require("../util/createObject");
var EmptyError_1 = require("../util/EmptyError");
function forkJoin() {

@@ -19,6 +20,6 @@ var args = [];

var _a = (0, argsArgArrayOrObject_1.argsArgArrayOrObject)(args), sources = _a.args, keys = _a.keys;
var result = new Observable_1.Observable(function (subscriber) {
var result = new Observable_1.Observable(function (destination) {
var length = sources.length;
if (!length) {
subscriber.complete();
destination.complete();
return;

@@ -31,15 +32,23 @@ }

var hasValue = false;
(0, from_1.from)(sources[sourceIndex]).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (!hasValue) {
hasValue = true;
remainingEmissions--;
}
values[sourceIndex] = value;
}, function () { return remainingCompletions--; }, undefined, function () {
if (!remainingCompletions || !hasValue) {
if (!remainingEmissions) {
subscriber.next(keys ? (0, createObject_1.createObject)(keys, values) : values);
(0, from_1.from)(sources[sourceIndex]).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (!hasValue) {
hasValue = true;
remainingEmissions--;
}
subscriber.complete();
}
values[sourceIndex] = value;
},
complete: function () { return remainingCompletions--; },
finalize: function () {
if (!remainingCompletions || !hasValue) {
if (remainingEmissions === 0) {
destination.next(keys ? (0, createObject_1.createObject)(keys, values) : values);
destination.complete();
}
else {
destination.error(new EmptyError_1.EmptyError());
}
}
},
}));

@@ -46,0 +55,0 @@ };

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.subscribeToArray = exports.fromArrayLike = exports.from = void 0;
exports.subscribeToArray = exports.fromPromise = exports.fromArrayLike = exports.from = void 0;
var isArrayLike_1 = require("../util/isArrayLike");

@@ -124,2 +124,3 @@ var isPromise_1 = require("../util/isPromise");

}
exports.fromPromise = fromPromise;
function fromIterable(iterable) {

@@ -209,3 +210,6 @@ return new Observable_1.Observable(function (subscriber) {

var length = array.length;
for (var i = 0; i < length && !subscriber.closed; i++) {
for (var i = 0; i < length; i++) {
if (subscriber.closed) {
return;
}
subscriber.next(array[i]);

@@ -212,0 +216,0 @@ }

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

var argsOrArgArray_1 = require("../util/argsOrArgArray");
var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var noop_1 = require("../util/noop");

@@ -16,3 +16,3 @@ var from_1 = require("./from");

var nextSources = (0, argsOrArgArray_1.argsOrArgArray)(sources);
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var sourceIndex = 0;

@@ -29,3 +29,3 @@ var subscribeNext = function () {

}
var innerSubscriber = new OperatorSubscriber_1.OperatorSubscriber(subscriber, undefined, noop_1.noop, noop_1.noop);
var innerSubscriber = (0, Subscriber_1.operate)({ destination: destination, error: noop_1.noop, complete: noop_1.noop });
nextSource.subscribe(innerSubscriber);

@@ -35,3 +35,3 @@ innerSubscriber.add(subscribeNext);

else {
subscriber.complete();
destination.complete();
}

@@ -38,0 +38,0 @@ };

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

var argsOrArgArray_1 = require("../util/argsOrArgArray");
var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function race() {

@@ -19,16 +19,19 @@ var sources = [];

function raceInit(sources) {
return function (subscriber) {
return function (destination) {
var subscriptions = [];
var _loop_1 = function (i) {
subscriptions.push((0, from_1.from)(sources[i]).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (subscriptions) {
for (var s = 0; s < subscriptions.length; s++) {
s !== i && subscriptions[s].unsubscribe();
subscriptions.push((0, from_1.from)(sources[i]).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (subscriptions) {
for (var s = 0; s < subscriptions.length; s++) {
s !== i && subscriptions[s].unsubscribe();
}
subscriptions = null;
}
subscriptions = null;
}
subscriber.next(value);
destination.next(value);
},
})));
};
for (var i = 0; subscriptions && !subscriber.closed && i < sources.length; i++) {
for (var i = 0; subscriptions && !destination.closed && i < sources.length; i++) {
_loop_1(i);

@@ -35,0 +38,0 @@ }

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

var empty_1 = require("./empty");
var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var args_1 = require("../util/args");

@@ -44,24 +44,28 @@ function zip() {

return sources.length
? new Observable_1.Observable(function (subscriber) {
? new Observable_1.Observable(function (destination) {
var buffers = sources.map(function () { return []; });
var completed = sources.map(function () { return false; });
subscriber.add(function () {
destination.add(function () {
buffers = completed = null;
});
var _loop_1 = function (sourceIndex) {
(0, from_1.from)(sources[sourceIndex]).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
buffers[sourceIndex].push(value);
if (buffers.every(function (buffer) { return buffer.length; })) {
var result = buffers.map(function (buffer) { return buffer.shift(); });
subscriber.next(resultSelector ? resultSelector.apply(void 0, __spreadArray([], __read(result), false)) : result);
if (buffers.some(function (buffer, i) { return !buffer.length && completed[i]; })) {
subscriber.complete();
(0, from_1.from)(sources[sourceIndex]).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
buffers[sourceIndex].push(value);
if (buffers.every(function (buffer) { return buffer.length; })) {
var result = buffers.map(function (buffer) { return buffer.shift(); });
destination.next(resultSelector ? resultSelector.apply(void 0, __spreadArray([], __read(result), false)) : result);
if (buffers.some(function (buffer, i) { return !buffer.length && completed[i]; })) {
destination.complete();
}
}
}
}, function () {
completed[sourceIndex] = true;
!buffers[sourceIndex].length && subscriber.complete();
},
complete: function () {
completed[sourceIndex] = true;
!buffers[sourceIndex].length && destination.complete();
},
}));
};
for (var sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {
for (var sourceIndex = 0; !destination.closed && sourceIndex < sources.length; sourceIndex++) {
_loop_1(sourceIndex);

@@ -68,0 +72,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.audit = void 0;
var Subscriber_1 = require("../Subscriber");
var Observable_1 = require("../Observable");
var from_1 = require("../observable/from");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function audit(durationSelector) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var hasValue = false;

@@ -21,19 +21,27 @@ var lastValue = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}
isComplete && subscriber.complete();
isComplete && destination.complete();
};
var cleanupDuration = function () {
durationSubscriber = null;
isComplete && subscriber.complete();
isComplete && destination.complete();
};
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
hasValue = true;
lastValue = value;
if (!durationSubscriber) {
(0, from_1.from)(durationSelector(value)).subscribe((durationSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, endDuration, cleanupDuration)));
}
}, function () {
isComplete = true;
(!hasValue || !durationSubscriber || durationSubscriber.closed) && subscriber.complete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
hasValue = true;
lastValue = value;
if (!durationSubscriber) {
(0, from_1.from)(durationSelector(value)).subscribe((durationSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: endDuration,
complete: cleanupDuration,
})));
}
},
complete: function () {
isComplete = true;
(!hasValue || !durationSubscriber || durationSubscriber.closed) && destination.complete();
},
}));

@@ -40,0 +48,0 @@ });

@@ -6,17 +6,25 @@ "use strict";

var noop_1 = require("../util/noop");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");
function buffer(closingNotifier) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var currentBuffer = [];
(0, from_1.from)(closingNotifier).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
var b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
}, noop_1.noop));
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return currentBuffer.push(value); }, function () {
subscriber.next(currentBuffer);
subscriber.complete();
(0, from_1.from)(closingNotifier).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function () {
var b = currentBuffer;
currentBuffer = [];
destination.next(b);
},
complete: noop_1.noop,
}));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) { return currentBuffer.push(value); },
complete: function () {
destination.next(currentBuffer);
destination.complete();
},
}));
return function () {

@@ -23,0 +31,0 @@ currentBuffer = null;

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var arrRemove_1 = require("../util/arrRemove");

@@ -23,62 +23,67 @@ function bufferCount(bufferSize, startBufferEvery) {

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var buffers = [];
var count = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var e_1, _a, e_2, _b;
var toEmit = null;
if (count++ % startBufferEvery === 0) {
buffers.push([]);
}
try {
for (var buffers_1 = __values(buffers), buffers_1_1 = buffers_1.next(); !buffers_1_1.done; buffers_1_1 = buffers_1.next()) {
var buffer = buffers_1_1.value;
buffer.push(value);
if (bufferSize <= buffer.length) {
toEmit = toEmit !== null && toEmit !== void 0 ? toEmit : [];
toEmit.push(buffer);
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var e_1, _a, e_2, _b;
var toEmit = null;
if (count++ % startBufferEvery === 0) {
buffers.push([]);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (buffers_1_1 && !buffers_1_1.done && (_a = buffers_1.return)) _a.call(buffers_1);
}
finally { if (e_1) throw e_1.error; }
}
if (toEmit) {
try {
for (var toEmit_1 = __values(toEmit), toEmit_1_1 = toEmit_1.next(); !toEmit_1_1.done; toEmit_1_1 = toEmit_1.next()) {
var buffer = toEmit_1_1.value;
(0, arrRemove_1.arrRemove)(buffers, buffer);
subscriber.next(buffer);
for (var buffers_1 = __values(buffers), buffers_1_1 = buffers_1.next(); !buffers_1_1.done; buffers_1_1 = buffers_1.next()) {
var buffer = buffers_1_1.value;
buffer.push(value);
if (bufferSize <= buffer.length) {
toEmit = toEmit !== null && toEmit !== void 0 ? toEmit : [];
toEmit.push(buffer);
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (toEmit_1_1 && !toEmit_1_1.done && (_b = toEmit_1.return)) _b.call(toEmit_1);
if (buffers_1_1 && !buffers_1_1.done && (_a = buffers_1.return)) _a.call(buffers_1);
}
finally { if (e_2) throw e_2.error; }
finally { if (e_1) throw e_1.error; }
}
}
}, function () {
var e_3, _a;
try {
for (var buffers_2 = __values(buffers), buffers_2_1 = buffers_2.next(); !buffers_2_1.done; buffers_2_1 = buffers_2.next()) {
var buffer = buffers_2_1.value;
subscriber.next(buffer);
if (toEmit) {
try {
for (var toEmit_1 = __values(toEmit), toEmit_1_1 = toEmit_1.next(); !toEmit_1_1.done; toEmit_1_1 = toEmit_1.next()) {
var buffer = toEmit_1_1.value;
(0, arrRemove_1.arrRemove)(buffers, buffer);
destination.next(buffer);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (toEmit_1_1 && !toEmit_1_1.done && (_b = toEmit_1.return)) _b.call(toEmit_1);
}
finally { if (e_2) throw e_2.error; }
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
},
complete: function () {
var e_3, _a;
try {
if (buffers_2_1 && !buffers_2_1.done && (_a = buffers_2.return)) _a.call(buffers_2);
for (var buffers_2 = __values(buffers), buffers_2_1 = buffers_2.next(); !buffers_2_1.done; buffers_2_1 = buffers_2.next()) {
var buffer = buffers_2_1.value;
destination.next(buffer);
}
}
finally { if (e_3) throw e_3.error; }
}
subscriber.complete();
}, undefined, function () {
buffers = null;
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (buffers_2_1 && !buffers_2_1.done && (_a = buffers_2.return)) _a.call(buffers_2);
}
finally { if (e_3) throw e_3.error; }
}
destination.complete();
},
finalize: function () {
buffers = null;
},
}));

@@ -85,0 +90,0 @@ });

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var arrRemove_1 = require("../util/arrRemove");

@@ -33,3 +33,3 @@ var async_1 = require("../scheduler/async");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var bufferRecords = [];

@@ -41,3 +41,3 @@ var restartOnEmit = false;

(0, arrRemove_1.arrRemove)(bufferRecords, record);
subscriber.next(buffer);
destination.next(buffer);
restartOnEmit && startBuffer();

@@ -48,3 +48,3 @@ };

var subs = new Subscription_1.Subscription();
subscriber.add(subs);
destination.add(subs);
var buffer = [];

@@ -60,3 +60,3 @@ var record_1 = {

if (bufferCreationInterval !== null && bufferCreationInterval >= 0) {
(0, executeSchedule_1.executeSchedule)(subscriber, scheduler, startBuffer, bufferCreationInterval, true);
(0, executeSchedule_1.executeSchedule)(destination, scheduler, startBuffer, bufferCreationInterval, true);
}

@@ -67,28 +67,33 @@ else {

startBuffer();
var bufferTimeSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var e_1, _a;
var recordsCopy = bufferRecords.slice();
try {
for (var recordsCopy_1 = __values(recordsCopy), recordsCopy_1_1 = recordsCopy_1.next(); !recordsCopy_1_1.done; recordsCopy_1_1 = recordsCopy_1.next()) {
var record = recordsCopy_1_1.value;
var buffer = record.buffer;
buffer.push(value);
maxBufferSize <= buffer.length && emit(record);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
var bufferTimeSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var e_1, _a;
var recordsCopy = bufferRecords.slice();
try {
if (recordsCopy_1_1 && !recordsCopy_1_1.done && (_a = recordsCopy_1.return)) _a.call(recordsCopy_1);
for (var recordsCopy_1 = __values(recordsCopy), recordsCopy_1_1 = recordsCopy_1.next(); !recordsCopy_1_1.done; recordsCopy_1_1 = recordsCopy_1.next()) {
var record = recordsCopy_1_1.value;
var buffer = record.buffer;
buffer.push(value);
maxBufferSize <= buffer.length && emit(record);
}
}
finally { if (e_1) throw e_1.error; }
}
}, function () {
while (bufferRecords === null || bufferRecords === void 0 ? void 0 : bufferRecords.length) {
subscriber.next(bufferRecords.shift().buffer);
}
bufferTimeSubscriber === null || bufferTimeSubscriber === void 0 ? void 0 : bufferTimeSubscriber.unsubscribe();
subscriber.complete();
subscriber.unsubscribe();
}, undefined, function () { return (bufferRecords = null); });
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (recordsCopy_1_1 && !recordsCopy_1_1.done && (_a = recordsCopy_1.return)) _a.call(recordsCopy_1);
}
finally { if (e_1) throw e_1.error; }
}
},
complete: function () {
while (bufferRecords === null || bufferRecords === void 0 ? void 0 : bufferRecords.length) {
destination.next(bufferRecords.shift().buffer);
}
bufferTimeSubscriber === null || bufferTimeSubscriber === void 0 ? void 0 : bufferTimeSubscriber.unsubscribe();
destination.complete();
destination.unsubscribe();
},
finalize: function () { return (bufferRecords = null); },
});
source.subscribe(bufferTimeSubscriber);

@@ -95,0 +100,0 @@ });

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

var from_1 = require("../observable/from");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var noop_1 = require("../util/noop");

@@ -24,35 +24,43 @@ var arrRemove_1 = require("../util/arrRemove");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var buffers = [];
(0, from_1.from)(openings).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (openValue) {
var buffer = [];
buffers.push(buffer);
var closingSubscription = new Subscription_1.Subscription();
var emitBuffer = function () {
(0, arrRemove_1.arrRemove)(buffers, buffer);
subscriber.next(buffer);
closingSubscription.unsubscribe();
};
closingSubscription.add((0, from_1.from)(closingSelector(openValue)).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, emitBuffer, noop_1.noop)));
}, noop_1.noop));
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var e_1, _a;
try {
for (var buffers_1 = __values(buffers), buffers_1_1 = buffers_1.next(); !buffers_1_1.done; buffers_1_1 = buffers_1.next()) {
var buffer = buffers_1_1.value;
buffer.push(value);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
(0, from_1.from)(openings).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (openValue) {
var buffer = [];
buffers.push(buffer);
var closingSubscription = new Subscription_1.Subscription();
var emitBuffer = function () {
(0, arrRemove_1.arrRemove)(buffers, buffer);
destination.next(buffer);
closingSubscription.unsubscribe();
};
closingSubscription.add((0, from_1.from)(closingSelector(openValue)).subscribe((0, Subscriber_1.operate)({ destination: destination, next: emitBuffer, complete: noop_1.noop })));
},
complete: noop_1.noop,
}));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var e_1, _a;
try {
if (buffers_1_1 && !buffers_1_1.done && (_a = buffers_1.return)) _a.call(buffers_1);
for (var buffers_1 = __values(buffers), buffers_1_1 = buffers_1.next(); !buffers_1_1.done; buffers_1_1 = buffers_1.next()) {
var buffer = buffers_1_1.value;
buffer.push(value);
}
}
finally { if (e_1) throw e_1.error; }
}
}, function () {
while (buffers.length > 0) {
subscriber.next(buffers.shift());
}
subscriber.complete();
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (buffers_1_1 && !buffers_1_1.done && (_a = buffers_1.return)) _a.call(buffers_1);
}
finally { if (e_1) throw e_1.error; }
}
},
complete: function () {
while (buffers.length > 0) {
destination.next(buffers.shift());
}
destination.complete();
},
}));

@@ -59,0 +67,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bufferWhen = void 0;
var Subscriber_1 = require("../Subscriber");
var Observable_1 = require("../Observable");
var noop_1 = require("../util/noop");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var from_1 = require("../observable/from");

@@ -18,9 +18,18 @@ function bufferWhen(closingSelector) {

b && subscriber.next(b);
(0, from_1.from)(closingSelector()).subscribe((closingSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, openBuffer, noop_1.noop)));
(0, from_1.from)(closingSelector()).subscribe((closingSubscriber = (0, Subscriber_1.operate)({
destination: subscriber,
next: openBuffer,
complete: noop_1.noop,
})));
};
openBuffer();
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return buffer === null || buffer === void 0 ? void 0 : buffer.push(value); }, function () {
buffer && subscriber.next(buffer);
subscriber.complete();
}, undefined, function () { return (buffer = closingSubscriber = null); }));
source.subscribe((0, Subscriber_1.operate)({
destination: subscriber,
next: function (value) { return buffer === null || buffer === void 0 ? void 0 : buffer.push(value); },
complete: function () {
buffer && subscriber.next(buffer);
subscriber.complete();
},
finalize: function () { return (buffer = closingSubscriber = null); },
}));
});

@@ -27,0 +36,0 @@ };

@@ -6,19 +6,22 @@ "use strict";

var from_1 = require("../observable/from");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function catchError(selector) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var innerSub = null;
var syncUnsub = false;
var handledResult;
innerSub = source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, undefined, function (err) {
handledResult = (0, from_1.from)(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(subscriber);
}
else {
syncUnsub = true;
}
innerSub = source.subscribe((0, Subscriber_1.operate)({
destination: destination,
error: function (err) {
handledResult = (0, from_1.from)(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(destination);
}
else {
syncUnsub = true;
}
},
}));

@@ -28,3 +31,3 @@ if (syncUnsub) {

innerSub = null;
handledResult.subscribe(subscriber);
handledResult.subscribe(destination);
}

@@ -31,0 +34,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.debounce = void 0;
var Subscriber_1 = require("../Subscriber");
var Observable_1 = require("../Observable");
var noop_1 = require("../util/noop");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var from_1 = require("../observable/from");
function debounce(durationSelector) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var hasValue = false;

@@ -21,16 +21,21 @@ var lastValue = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}
};
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
hasValue = true;
lastValue = value;
durationSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, emit, noop_1.noop);
(0, from_1.from)(durationSelector(value)).subscribe(durationSubscriber);
}, function () {
emit();
subscriber.complete();
}, undefined, function () {
lastValue = durationSubscriber = null;
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
hasValue = true;
lastValue = value;
durationSubscriber = (0, Subscriber_1.operate)({ destination: destination, next: emit, complete: noop_1.noop });
(0, from_1.from)(durationSelector(value)).subscribe(durationSubscriber);
},
complete: function () {
emit();
destination.complete();
},
finalize: function () {
lastValue = durationSubscriber = null;
},
}));

@@ -37,0 +42,0 @@ });

@@ -6,7 +6,7 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function debounceTime(dueTime, scheduler) {
if (scheduler === void 0) { scheduler = async_1.asyncScheduler; }
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var activeTask = null;

@@ -24,3 +24,3 @@ var lastValue = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}

@@ -33,3 +33,3 @@ };

activeTask = this.schedule(undefined, targetTime - now);
subscriber.add(activeTask);
destination.add(activeTask);
return;

@@ -39,16 +39,21 @@ }

}
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
lastValue = value;
lastTime = scheduler.now();
if (!activeTask) {
scheduling = true;
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
scheduling = false;
subscriber.add(activeTask);
}
}, function () {
emit();
subscriber.complete();
}, undefined, function () {
lastValue = activeTask = null;
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
lastValue = value;
lastTime = scheduler.now();
if (!activeTask) {
scheduling = true;
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
scheduling = false;
destination.add(activeTask);
}
},
complete: function () {
emit();
destination.complete();
},
finalize: function () {
lastValue = activeTask = null;
},
}));

@@ -55,0 +60,0 @@ });

@@ -5,15 +5,19 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function defaultIfEmpty(defaultValue) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var hasValue = false;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
hasValue = true;
subscriber.next(value);
}, function () {
if (!hasValue) {
subscriber.next(defaultValue);
}
subscriber.complete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
hasValue = true;
destination.next(value);
},
complete: function () {
if (!hasValue) {
destination.next(defaultValue);
}
destination.complete();
},
}));

@@ -20,0 +24,0 @@ });

@@ -6,7 +6,7 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function dematerialize() {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (notification) { return (0, Notification_1.observeNotification)(notification, subscriber); }));
return new Observable_1.Observable(function (destination) {
source.subscribe((0, Subscriber_1.operate)({ destination: destination, next: function (notification) { return (0, Notification_1.observeNotification)(notification, destination); } }));
});

@@ -13,0 +13,0 @@ };

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var noop_1 = require("../util/noop");

@@ -11,12 +11,15 @@ var from_1 = require("../observable/from");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var distinctKeys = new Set();
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
subscriber.next(value);
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
destination.next(value);
}
},
}));
flushes && (0, from_1.from)(flushes).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () { return distinctKeys.clear(); }, noop_1.noop));
flushes && (0, from_1.from)(flushes).subscribe((0, Subscriber_1.operate)({ destination: destination, next: function () { return distinctKeys.clear(); }, complete: noop_1.noop }));
});

@@ -23,0 +26,0 @@ };

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function distinctUntilChanged(comparator, keySelector) {

@@ -12,12 +12,15 @@ if (keySelector === void 0) { keySelector = identity_1.identity; }

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var previousKey;
var first = true;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var currentKey = keySelector(value);
if (first || !comparator(previousKey, currentKey)) {
first = false;
previousKey = currentKey;
subscriber.next(value);
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var currentKey = keySelector(value);
if (first || !comparator(previousKey, currentKey)) {
first = false;
previousKey = currentKey;
destination.next(value);
}
},
}));

@@ -24,0 +27,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.endWith = void 0;
var Observable_1 = require("../Observable");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");
var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("../operators/OperatorSubscriber");
function endWith() {

@@ -13,5 +13,8 @@ var values = [];

return function (source) {
return new Observable_1.Observable(function (subscriber) {
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, function () {
(0, from_1.subscribeToArray)(values, subscriber);
return new Observable_1.Observable(function (destination) {
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
complete: function () {
(0, from_1.subscribeToArray)(values, destination);
},
}));

@@ -18,0 +21,0 @@ });

@@ -5,15 +5,19 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function every(predicate, thisArg) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (!predicate.call(thisArg, value, index++, source)) {
subscriber.next(false);
subscriber.complete();
}
}, function () {
subscriber.next(true);
subscriber.complete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (!predicate.call(thisArg, value, index++, source)) {
destination.next(false);
destination.complete();
}
},
complete: function () {
destination.next(true);
destination.complete();
},
}));

@@ -20,0 +24,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.exhaustMap = void 0;
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");
var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function exhaustMap(project) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var index = 0;
var innerSub = null;
var isComplete = false;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (outerValue) {
if (!innerSub) {
innerSub = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, function () {
innerSub = null;
isComplete && subscriber.complete();
});
(0, from_1.from)(project(outerValue, index++)).subscribe(innerSub);
}
}, function () {
isComplete = true;
!innerSub && subscriber.complete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (outerValue) {
if (!innerSub) {
innerSub = (0, Subscriber_1.operate)({
destination: destination,
complete: function () {
innerSub = null;
isComplete && destination.complete();
},
});
(0, from_1.from)(project(outerValue, index++)).subscribe(innerSub);
}
},
complete: function () {
isComplete = true;
!innerSub && destination.complete();
},
}));

@@ -25,0 +32,0 @@ });

@@ -5,8 +5,8 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function filter(predicate, thisArg) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
source.subscribe((0, Subscriber_1.operate)({ destination: destination, next: function (value) { return predicate.call(thisArg, value, index++) && destination.next(value); } }));
});

@@ -13,0 +13,0 @@ };

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function find(predicate) {

@@ -11,14 +11,18 @@ return function (source) { return new Observable_1.Observable(function (subscriber) { return createFind(predicate, 'value', source, subscriber); }); };

exports.find = find;
function createFind(predicate, emit, source, subscriber) {
function createFind(predicate, emit, source, destination) {
var findIndex = emit === 'index';
var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var i = index++;
if (predicate(value, i, source)) {
subscriber.next(findIndex ? i : value);
subscriber.complete();
}
}, function () {
subscriber.next(findIndex ? -1 : undefined);
subscriber.complete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var i = index++;
if (predicate(value, i, source)) {
destination.next(findIndex ? i : value);
destination.complete();
}
},
complete: function () {
destination.next(findIndex ? -1 : undefined);
destination.complete();
},
}));

@@ -25,0 +29,0 @@ }

@@ -7,6 +7,6 @@ "use strict";

var Subject_1 = require("../Subject");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function groupBy(keySelector, elementOrOptions, duration, connector) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var element;

@@ -22,42 +22,40 @@ if (!elementOrOptions || typeof elementOrOptions === 'function') {

groups.forEach(cb);
cb(subscriber);
cb(destination);
};
var handleError = function (err) { return notify(function (consumer) { return consumer.error(err); }); };
var activeGroups = 0;
var teardownAttempted = false;
var groupBySourceSubscriber = new OperatorSubscriber_1.OperatorSubscriber(subscriber, function (value) {
try {
var key_1 = keySelector(value);
var group_1 = groups.get(key_1);
if (!group_1) {
groups.set(key_1, (group_1 = connector ? connector() : new Subject_1.Subject()));
var grouped = createGroupedObservable(key_1, group_1);
subscriber.next(grouped);
if (duration) {
var durationSubscriber_1 = (0, OperatorSubscriber_1.createOperatorSubscriber)(group_1, function () {
group_1.complete();
durationSubscriber_1 === null || durationSubscriber_1 === void 0 ? void 0 : durationSubscriber_1.unsubscribe();
}, undefined, undefined, function () { return groups.delete(key_1); });
groupBySourceSubscriber.add((0, from_1.from)(duration(grouped)).subscribe(durationSubscriber_1));
var groupBySourceSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
try {
var key_1 = keySelector(value);
var group_1 = groups.get(key_1);
if (!group_1) {
groups.set(key_1, (group_1 = connector ? connector() : new Subject_1.Subject()));
var grouped = createGroupedObservable(key_1, group_1);
destination.next(grouped);
if (duration) {
var durationSubscriber_1 = (0, Subscriber_1.operate)({
destination: group_1,
next: function () {
group_1.complete();
durationSubscriber_1 === null || durationSubscriber_1 === void 0 ? void 0 : durationSubscriber_1.unsubscribe();
},
finalize: function () { return groups.delete(key_1); },
});
groupBySourceSubscriber.add((0, from_1.from)(duration(grouped)).subscribe(durationSubscriber_1));
}
}
group_1.next(element ? element(value) : value);
}
group_1.next(element ? element(value) : value);
}
catch (err) {
handleError(err);
}
}, function () { return notify(function (consumer) { return consumer.complete(); }); }, handleError, function () { return groups.clear(); }, function () {
teardownAttempted = true;
return activeGroups === 0;
catch (err) {
handleError(err);
}
},
error: handleError,
complete: function () { return notify(function (consumer) { return consumer.complete(); }); },
finalize: function () { return groups.clear(); },
});
source.subscribe(groupBySourceSubscriber);
function createGroupedObservable(key, groupSubject) {
var result = new Observable_1.Observable(function (groupSubscriber) {
activeGroups++;
var innerSub = groupSubject.subscribe(groupSubscriber);
return function () {
innerSub.unsubscribe();
--activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe();
};
});
var result = new Observable_1.Observable(function (groupSubscriber) { return groupSubject.subscribe(groupSubscriber); });
result.key = key;

@@ -64,0 +62,0 @@ return result;

@@ -5,8 +5,8 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var noop_1 = require("../util/noop");
function ignoreElements() {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, noop_1.noop));
return new Observable_1.Observable(function (destination) {
source.subscribe((0, Subscriber_1.operate)({ destination: destination, next: noop_1.noop }));
});

@@ -13,0 +13,0 @@ };

@@ -5,12 +5,16 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function isEmpty() {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
subscriber.next(false);
subscriber.complete();
}, function () {
subscriber.next(true);
subscriber.complete();
return new Observable_1.Observable(function (destination) {
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function () {
destination.next(false);
destination.complete();
},
complete: function () {
destination.next(true);
destination.complete();
},
}));

@@ -17,0 +21,0 @@ });

@@ -5,9 +5,12 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function map(project) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
subscriber.next(project(value, index++));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
destination.next(project(value, index++));
},
}));

@@ -14,0 +17,0 @@ });

@@ -6,14 +6,19 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function materialize() {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
subscriber.next((0, NotificationFactories_1.nextNotification)(value));
}, function () {
subscriber.next(NotificationFactories_1.COMPLETE_NOTIFICATION);
subscriber.complete();
}, function (error) {
subscriber.next((0, NotificationFactories_1.errorNotification)(error));
subscriber.complete();
return new Observable_1.Observable(function (destination) {
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
destination.next((0, NotificationFactories_1.nextNotification)(value));
},
error: function (error) {
destination.next((0, NotificationFactories_1.errorNotification)(error));
destination.complete();
},
complete: function () {
destination.next(NotificationFactories_1.COMPLETE_NOTIFICATION);
destination.complete();
},
}));

@@ -20,0 +25,0 @@ });

@@ -5,5 +5,5 @@ "use strict";

var from_1 = require("../observable/from");
var Subscriber_1 = require("../Subscriber");
var executeSchedule_1 = require("../util/executeSchedule");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
function mergeInternals(source, destination, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
var buffer = [];

@@ -15,3 +15,3 @@ var active = 0;

if (isComplete && !buffer.length && !active) {
subscriber.complete();
destination.complete();
}

@@ -21,42 +21,51 @@ };

var doInnerSub = function (value) {
expand && subscriber.next(value);
expand && destination.next(value);
active++;
var innerComplete = false;
(0, from_1.from)(project(value, index++)).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (innerValue) {
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
if (expand) {
outerNext(innerValue);
}
else {
subscriber.next(innerValue);
}
}, function () {
innerComplete = true;
}, undefined, function () {
if (innerComplete) {
try {
active--;
var _loop_1 = function () {
var bufferedValue = buffer.shift();
if (innerSubScheduler) {
(0, executeSchedule_1.executeSchedule)(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
(0, from_1.from)(project(value, index++)).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (innerValue) {
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
if (expand) {
outerNext(innerValue);
}
else {
destination.next(innerValue);
}
},
complete: function () {
innerComplete = true;
},
finalize: function () {
if (innerComplete) {
try {
active--;
var _loop_1 = function () {
var bufferedValue = buffer.shift();
if (innerSubScheduler) {
(0, executeSchedule_1.executeSchedule)(destination, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
}
else {
doInnerSub(bufferedValue);
}
};
while (buffer.length && active < concurrent) {
_loop_1();
}
else {
doInnerSub(bufferedValue);
}
};
while (buffer.length && active < concurrent) {
_loop_1();
checkComplete();
}
checkComplete();
catch (err) {
destination.error(err);
}
}
catch (err) {
subscriber.error(err);
}
}
},
}));
};
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, outerNext, function () {
isComplete = true;
checkComplete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: outerNext,
complete: function () {
isComplete = true;
checkComplete();
},
}));

@@ -63,0 +72,0 @@ return function () {

@@ -6,8 +6,13 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function observeOn(scheduler, delay) {
if (delay === void 0) { delay = 0; }
return function (source) {
return new Observable_1.Observable(function (subscriber) {
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return (0, executeSchedule_1.executeSchedule)(subscriber, scheduler, function () { return subscriber.next(value); }, delay); }, function () { return (0, executeSchedule_1.executeSchedule)(subscriber, scheduler, function () { return subscriber.complete(); }, delay); }, function (err) { return (0, executeSchedule_1.executeSchedule)(subscriber, scheduler, function () { return subscriber.error(err); }, delay); }));
return new Observable_1.Observable(function (destination) {
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) { return (0, executeSchedule_1.executeSchedule)(destination, scheduler, function () { return destination.next(value); }, delay); },
error: function (err) { return (0, executeSchedule_1.executeSchedule)(destination, scheduler, function () { return destination.error(err); }, delay); },
complete: function () { return (0, executeSchedule_1.executeSchedule)(destination, scheduler, function () { return destination.complete(); }, delay); },
}));
});

@@ -14,0 +19,0 @@ };

@@ -5,13 +5,16 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function pairwise() {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var prev;
var hasPrev = false;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var p = prev;
prev = value;
hasPrev && subscriber.next([p, value]);
hasPrev = true;
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var p = prev;
prev = value;
hasPrev && destination.next([p, value]);
hasPrev = true;
},
}));

@@ -18,0 +21,0 @@ });

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");

@@ -25,3 +25,3 @@ var timer_1 = require("../observable/timer");

: function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var soFar = 0;

@@ -34,5 +34,8 @@ var sourceSub;

var notifier = typeof delay === 'number' ? (0, timer_1.timer)(delay) : (0, from_1.from)(delay(soFar));
var notifierSubscriber_1 = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
notifierSubscriber_1.unsubscribe();
subscribeToSource();
var notifierSubscriber_1 = (0, Subscriber_1.operate)({
destination: destination,
next: function () {
notifierSubscriber_1.unsubscribe();
subscribeToSource();
},
});

@@ -47,14 +50,17 @@ notifier.subscribe(notifierSubscriber_1);

var syncUnsub = false;
sourceSub = source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, function () {
if (++soFar < count) {
if (sourceSub) {
resubscribe();
sourceSub = source.subscribe((0, Subscriber_1.operate)({
destination: destination,
complete: function () {
if (++soFar < count) {
if (sourceSub) {
resubscribe();
}
else {
syncUnsub = true;
}
}
else {
syncUnsub = true;
destination.complete();
}
}
else {
subscriber.complete();
}
},
}));

@@ -61,0 +67,0 @@ if (syncUnsub) {

@@ -7,6 +7,6 @@ "use strict";

var Subject_1 = require("../Subject");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function repeatWhen(notifier) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var innerSub;

@@ -17,16 +17,20 @@ var syncResub = false;

var isMainComplete = false;
var checkComplete = function () { return isMainComplete && isNotifierComplete && (subscriber.complete(), true); };
var checkComplete = function () { return isMainComplete && isNotifierComplete && (destination.complete(), true); };
var getCompletionSubject = function () {
if (!completions$) {
completions$ = new Subject_1.Subject();
(0, from_1.from)(notifier(completions$)).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
if (innerSub) {
subscribeForRepeatWhen();
}
else {
syncResub = true;
}
}, function () {
isNotifierComplete = true;
checkComplete();
(0, from_1.from)(notifier(completions$)).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function () {
if (innerSub) {
subscribeForRepeatWhen();
}
else {
syncResub = true;
}
},
complete: function () {
isNotifierComplete = true;
checkComplete();
},
}));

@@ -38,5 +42,8 @@ }

isMainComplete = false;
innerSub = source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, function () {
isMainComplete = true;
!checkComplete() && getCompletionSubject().next();
innerSub = source.subscribe((0, Subscriber_1.operate)({
destination: destination,
complete: function () {
isMainComplete = true;
!checkComplete() && getCompletionSubject().next();
},
}));

@@ -43,0 +50,0 @@ if (syncResub) {

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var identity_1 = require("../util/identity");

@@ -25,3 +25,3 @@ var timer_1 = require("../observable/timer");

: function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var soFar = 0;

@@ -31,36 +31,44 @@ var innerSub;

var syncUnsub = false;
innerSub = source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (resetOnSuccess) {
soFar = 0;
}
subscriber.next(value);
}, undefined, function (err) {
if (soFar++ < count) {
var resub_1 = function () {
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
subscribeForRetry();
innerSub = source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (resetOnSuccess) {
soFar = 0;
}
destination.next(value);
},
error: function (err) {
if (soFar++ < count) {
var resub_1 = function () {
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
subscribeForRetry();
}
else {
syncUnsub = true;
}
};
if (delay != null) {
var notifier = typeof delay === 'number' ? (0, timer_1.timer)(delay) : (0, from_1.from)(delay(err, soFar));
var notifierSubscriber_1 = (0, Subscriber_1.operate)({
destination: destination,
next: function () {
notifierSubscriber_1.unsubscribe();
resub_1();
},
complete: function () {
destination.complete();
},
});
notifier.subscribe(notifierSubscriber_1);
}
else {
syncUnsub = true;
resub_1();
}
};
if (delay != null) {
var notifier = typeof delay === 'number' ? (0, timer_1.timer)(delay) : (0, from_1.from)(delay(err, soFar));
var notifierSubscriber_1 = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
notifierSubscriber_1.unsubscribe();
resub_1();
}, function () {
subscriber.complete();
});
notifier.subscribe(notifierSubscriber_1);
}
else {
resub_1();
destination.error(err);
}
}
else {
subscriber.error(err);
}
},
}));

@@ -67,0 +75,0 @@ if (syncUnsub) {

@@ -7,6 +7,6 @@ "use strict";

var Subject_1 = require("../Subject");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function retryWhen(notifier) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var innerSub;

@@ -16,12 +16,18 @@ var syncResub = false;

var subscribeForRetryWhen = function () {
innerSub = source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, undefined, function (err) {
if (!errors$) {
errors$ = new Subject_1.Subject();
(0, from_1.from)(notifier(errors$)).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
return innerSub ? subscribeForRetryWhen() : (syncResub = true);
}));
}
if (errors$) {
errors$.next(err);
}
innerSub = source.subscribe((0, Subscriber_1.operate)({
destination: destination,
error: function (err) {
if (!errors$) {
errors$ = new Subject_1.Subject();
(0, from_1.from)(notifier(errors$)).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function () {
return innerSub ? subscribeForRetryWhen() : (syncResub = true);
},
}));
}
if (errors$) {
errors$.next(err);
}
},
}));

@@ -28,0 +34,0 @@ if (syncResub) {

@@ -7,20 +7,27 @@ "use strict";

var noop_1 = require("../util/noop");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function sample(notifier) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var hasValue = false;
var lastValue = null;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
hasValue = true;
lastValue = value;
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
hasValue = true;
lastValue = value;
},
}));
(0, from_1.from)(notifier).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
if (hasValue) {
hasValue = false;
var value = lastValue;
lastValue = null;
subscriber.next(value);
}
}, noop_1.noop));
(0, from_1.from)(notifier).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function () {
if (hasValue) {
hasValue = false;
var value = lastValue;
lastValue = null;
destination.next(value);
}
},
complete: noop_1.noop,
}));
});

@@ -27,0 +34,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.scanInternals = void 0;
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete, source, subscriber) {
var Subscriber_1 = require("../Subscriber");
function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete, source, destination) {
var hasState = hasSeed;
var state = seed;
var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var i = index++;
state = hasState
?
accumulator(state, value, i)
:
((hasState = true), value);
emitOnNext && subscriber.next(state);
}, emitBeforeComplete
? function () {
hasState && subscriber.next(state);
subscriber.complete();
}
: undefined));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var i = index++;
state = hasState
?
accumulator(state, value, i)
:
((hasState = true), value);
emitOnNext && destination.next(state);
},
complete: emitBeforeComplete
? function () {
hasState && destination.next(state);
destination.complete();
}
: undefined,
}));
}
exports.scanInternals = scanInternals;
//# sourceMappingURL=scanInternals.js.map

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");

@@ -11,23 +11,27 @@ function sequenceEqual(compareTo, comparator) {

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var aState = createState();
var bState = createState();
var emit = function (isEqual) {
subscriber.next(isEqual);
subscriber.complete();
destination.next(isEqual);
destination.complete();
};
var createSubscriber = function (selfState, otherState) {
var sequenceEqualSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (a) {
var buffer = otherState.buffer, complete = otherState.complete;
if (buffer.length === 0) {
complete ? emit(false) : selfState.buffer.push(a);
}
else {
!comparator(a, buffer.shift()) && emit(false);
}
}, function () {
selfState.complete = true;
var complete = otherState.complete, buffer = otherState.buffer;
complete && emit(buffer.length === 0);
sequenceEqualSubscriber === null || sequenceEqualSubscriber === void 0 ? void 0 : sequenceEqualSubscriber.unsubscribe();
var sequenceEqualSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: function (a) {
var buffer = otherState.buffer, complete = otherState.complete;
if (buffer.length === 0) {
complete ? emit(false) : selfState.buffer.push(a);
}
else {
!comparator(a, buffer.shift()) && emit(false);
}
},
complete: function () {
selfState.complete = true;
var complete = otherState.complete, buffer = otherState.buffer;
complete && emit(buffer.length === 0);
sequenceEqualSubscriber === null || sequenceEqualSubscriber === void 0 ? void 0 : sequenceEqualSubscriber.unsubscribe();
},
});

@@ -34,0 +38,0 @@ return sequenceEqualSubscriber;

@@ -8,6 +8,6 @@ "use strict";

var NotFoundError_1 = require("../util/NotFoundError");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function single(predicate) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var hasValue = false;

@@ -17,17 +17,21 @@ var singleValue;

var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
seenValue = true;
if (!predicate || predicate(value, index++, source)) {
hasValue && subscriber.error(new SequenceError_1.SequenceError('Too many matching values'));
hasValue = true;
singleValue = value;
}
}, function () {
if (hasValue) {
subscriber.next(singleValue);
subscriber.complete();
}
else {
subscriber.error(seenValue ? new NotFoundError_1.NotFoundError('No matching values') : new EmptyError_1.EmptyError());
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
seenValue = true;
if (!predicate || predicate(value, index++, source)) {
hasValue && destination.error(new SequenceError_1.SequenceError('Too many matching values'));
hasValue = true;
singleValue = value;
}
},
complete: function () {
if (hasValue) {
destination.next(singleValue);
destination.complete();
}
else {
destination.error(seenValue ? new NotFoundError_1.NotFoundError('No matching values') : new EmptyError_1.EmptyError());
}
},
}));

@@ -34,0 +38,0 @@ });

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function skipLast(skipCount) {

@@ -13,16 +13,19 @@ return skipCount <= 0

: function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var ring = new Array(skipCount);
var seen = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var valueIndex = seen++;
if (valueIndex < skipCount) {
ring[valueIndex] = value;
}
else {
var index = valueIndex % skipCount;
var oldValue = ring[index];
ring[index] = value;
subscriber.next(oldValue);
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var valueIndex = seen++;
if (valueIndex < skipCount) {
ring[valueIndex] = value;
}
else {
var index = valueIndex % skipCount;
var oldValue = ring[index];
ring[index] = value;
destination.next(oldValue);
}
},
}));

@@ -29,0 +32,0 @@ return function () {

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");

@@ -11,10 +11,14 @@ var noop_1 = require("../util/noop");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var taking = false;
var skipSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
skipSubscriber === null || skipSubscriber === void 0 ? void 0 : skipSubscriber.unsubscribe();
taking = true;
}, noop_1.noop);
var skipSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: function () {
skipSubscriber === null || skipSubscriber === void 0 ? void 0 : skipSubscriber.unsubscribe();
taking = true;
},
complete: noop_1.noop,
});
(0, from_1.from)(notifier).subscribe(skipSubscriber);
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return taking && subscriber.next(value); }));
source.subscribe((0, Subscriber_1.operate)({ destination: destination, next: function (value) { return taking && destination.next(value); } }));
});

@@ -21,0 +25,0 @@ };

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function skipWhile(predicate) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var taking = false;
var index = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return (taking || (taking = !predicate(value, index++))) && subscriber.next(value); }));
source.subscribe((0, Subscriber_1.operate)({ destination: destination, next: function (value) { return (taking || (taking = !predicate(value, index++))) && destination.next(value); } }));
});

@@ -14,0 +14,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startWith = void 0;
var concat_1 = require("../observable/concat");
var args_1 = require("../util/args");
var Observable_1 = require("../Observable");
var from_1 = require("../observable/from");
var Subscriber_1 = require("../Subscriber");
function startWith() {

@@ -12,6 +12,5 @@ var values = [];

}
var scheduler = (0, args_1.popScheduler)(values);
return function (source) {
return new Observable_1.Observable(function (subscriber) {
(scheduler ? (0, concat_1.concat)(values, source, scheduler) : (0, concat_1.concat)(values, source)).subscribe(subscriber);
return new Observable_1.Observable(function (destination) {
(0, from_1.subscribeToArray)(values, (0, Subscriber_1.operate)({ destination: destination, complete: function () { return source.subscribe(destination); } }));
});

@@ -18,0 +17,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.switchMap = void 0;
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");
var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
function switchMap(project) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var innerSubscriber = null;
var index = 0;
var isComplete = false;
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
var outerIndex = index++;
(0, from_1.from)(project(value, outerIndex)).subscribe((innerSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, undefined, function () {
innerSubscriber = null;
var checkComplete = function () { return isComplete && !innerSubscriber && destination.complete(); };
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
var outerIndex = index++;
(0, from_1.from)(project(value, outerIndex)).subscribe((innerSubscriber = (0, Subscriber_1.operate)({
destination: destination,
complete: function () {
innerSubscriber = null;
checkComplete();
},
})));
},
complete: function () {
isComplete = true;
checkComplete();
})));
}, function () {
isComplete = true;
checkComplete();
},
}));

@@ -25,0 +32,0 @@ });

@@ -6,10 +6,13 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function switchScan(accumulator, seed) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var state = seed;
(0, switchMap_1.switchMap)(function (value, index) { return accumulator(state, value, index); })(source).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (innerValue) {
state = innerValue;
subscriber.next(innerValue);
(0, switchMap_1.switchMap)(function (value, index) { return accumulator(state, value, index); })(source).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (innerValue) {
state = innerValue;
destination.next(innerValue);
},
}));

@@ -16,0 +19,0 @@ return function () {

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function take(count) {

@@ -13,13 +13,16 @@ return count <= 0

: function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var seen = 0;
var operatorSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (++seen < count) {
subscriber.next(value);
}
else {
operatorSubscriber.unsubscribe();
subscriber.next(value);
subscriber.complete();
}
var operatorSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (++seen < count) {
destination.next(value);
}
else {
operatorSubscriber.unsubscribe();
destination.next(value);
destination.complete();
}
},
});

@@ -26,0 +29,0 @@ source.subscribe(operatorSubscriber);

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function takeLast(count) {

@@ -12,16 +12,21 @@ return count <= 0

: function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var ring = new Array(count);
var counter = 0;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
ring[counter++ % count] = value;
}, function () {
var start = count <= counter ? counter : 0;
var total = Math.min(count, counter);
for (var n = 0; n < total; n++) {
subscriber.next(ring[(start + n) % count]);
}
subscriber.complete();
}, undefined, function () {
ring = null;
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
ring[counter++ % count] = value;
},
complete: function () {
var start = count <= counter ? counter : 0;
var total = Math.min(count, counter);
for (var n = 0; n < total; n++) {
destination.next(ring[(start + n) % count]);
}
destination.complete();
},
finalize: function () {
ring = null;
},
}));

@@ -28,0 +33,0 @@ });

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");

@@ -11,5 +11,5 @@ var noop_1 = require("../util/noop");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
(0, from_1.from)(notifier).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () { return subscriber.complete(); }, noop_1.noop));
!subscriber.closed && source.subscribe(subscriber);
return new Observable_1.Observable(function (destination) {
(0, from_1.from)(notifier).subscribe((0, Subscriber_1.operate)({ destination: destination, next: function () { return destination.complete(); }, complete: noop_1.noop }));
!destination.closed && source.subscribe(destination);
});

@@ -16,0 +16,0 @@ };

@@ -5,19 +5,22 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function takeWhile(predicate, inclusive) {
if (inclusive === void 0) { inclusive = false; }
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var index = 0;
var operatorSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (predicate(value, index++)) {
subscriber.next(value);
}
else {
operatorSubscriber.unsubscribe();
if (inclusive) {
subscriber.next(value);
var operatorSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (predicate(value, index++)) {
destination.next(value);
}
subscriber.complete();
}
else {
operatorSubscriber.unsubscribe();
if (inclusive) {
destination.next(value);
}
destination.complete();
}
},
});

@@ -24,0 +27,0 @@ source.subscribe(operatorSubscriber);

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var identity_1 = require("../util/identity");

@@ -13,26 +13,32 @@ function tap(observerOrNext) {

? function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var _a;
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
var isUnsub = true;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var _a;
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
subscriber.next(value);
}, function () {
var _a;
isUnsub = false;
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
subscriber.complete();
}, function (err) {
var _a;
isUnsub = false;
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
subscriber.error(err);
}, function () {
var _a, _b;
if (isUnsub) {
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
}
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var _a;
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
destination.next(value);
},
error: function (err) {
var _a;
isUnsub = false;
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
destination.error(err);
},
complete: function () {
var _a;
isUnsub = false;
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
destination.complete();
},
finalize: function () {
var _a, _b;
if (isUnsub) {
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
}
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
},
}));

@@ -39,0 +45,0 @@ });

@@ -5,7 +5,7 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");
function throttle(durationSelector, config) {
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var _a = config !== null && config !== void 0 ? config : {}, _b = _a.leading, leading = _b === void 0 ? true : _b, _c = _a.trailing, trailing = _c === void 0 ? false : _c;

@@ -21,3 +21,3 @@ var hasValue = false;

send();
isComplete && subscriber.complete();
isComplete && destination.complete();
}

@@ -27,6 +27,6 @@ };

throttled = null;
isComplete && subscriber.complete();
isComplete && destination.complete();
};
var startThrottle = function (value) {
return (throttled = (0, from_1.from)(durationSelector(value)).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, endThrottling, cleanupThrottling)));
return (throttled = (0, from_1.from)(durationSelector(value)).subscribe((0, Subscriber_1.operate)({ destination: destination, next: endThrottling, complete: cleanupThrottling })));
};

@@ -38,13 +38,17 @@ var send = function () {

sendValue = null;
subscriber.next(value);
destination.next(value);
!isComplete && startThrottle(value);
}
};
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
hasValue = true;
sendValue = value;
!(throttled && !throttled.closed) && (leading ? send() : startThrottle(value));
}, function () {
isComplete = true;
!(trailing && hasValue && throttled && !throttled.closed) && subscriber.complete();
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
hasValue = true;
sendValue = value;
!(throttled && !throttled.closed) && (leading ? send() : startThrottle(value));
},
complete: function () {
isComplete = true;
!(trailing && hasValue && throttled && !throttled.closed) && destination.complete();
},
}));

@@ -51,0 +55,0 @@ });

@@ -6,12 +6,16 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function throwIfEmpty(errorFactory) {
if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var hasValue = false;
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
hasValue = true;
subscriber.next(value);
}, function () { return (hasValue ? subscriber.complete() : subscriber.error(errorFactory())); }));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
hasValue = true;
destination.next(value);
},
complete: function () { return (hasValue ? destination.complete() : destination.error(errorFactory())); },
}));
});

@@ -18,0 +22,0 @@ };

@@ -6,13 +6,16 @@ "use strict";

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function timeInterval(scheduler) {
if (scheduler === void 0) { scheduler = async_1.asyncScheduler; }
return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var last = scheduler.now();
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var now = scheduler.now();
var interval = now - last;
last = now;
subscriber.next(new TimeInterval(value, interval));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var now = scheduler.now();
var interval = now - last;
last = now;
destination.next(new TimeInterval(value, interval));
},
}));

@@ -19,0 +22,0 @@ });

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,14 +23,16 @@ exports.timeout = exports.TimeoutError = void 0;

var from_1 = require("../observable/from");
var createErrorClass_1 = require("../util/createErrorClass");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var executeSchedule_1 = require("../util/executeSchedule");
exports.TimeoutError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function TimeoutErrorImpl(info) {
var TimeoutError = (function (_super) {
__extends(TimeoutError, _super);
function TimeoutError(info) {
if (info === void 0) { info = null; }
_super(this);
this.message = 'Timeout has occurred';
this.name = 'TimeoutError';
this.info = info;
};
});
var _this = _super.call(this, 'Timeout has occurred') || this;
_this.info = info;
_this.name = 'TimeoutError';
return _this;
}
return TimeoutError;
}(Error));
exports.TimeoutError = TimeoutError;
function timeout(config, schedulerArg) {

@@ -27,3 +44,3 @@ var _a = ((0, isDate_1.isValidDate)(config) ? { first: config } : typeof config === 'number' ? { each: config } : config), first = _a.first, each = _a.each, _b = _a.with, _with = _b === void 0 ? timeoutErrorFactory : _b, _c = _a.scheduler, scheduler = _c === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : async_1.asyncScheduler : _c, _d = _a.meta, meta = _d === void 0 ? null : _d;

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var originalSourceSubscription;

@@ -34,3 +51,3 @@ var timerSubscription;

var startTimer = function (delay) {
timerSubscription = (0, executeSchedule_1.executeSchedule)(subscriber, scheduler, function () {
timerSubscription = (0, executeSchedule_1.executeSchedule)(destination, scheduler, function () {
try {

@@ -42,19 +59,23 @@ originalSourceSubscription.unsubscribe();

seen: seen,
})).subscribe(subscriber);
})).subscribe(destination);
}
catch (err) {
subscriber.error(err);
destination.error(err);
}
}, delay);
};
originalSourceSubscription = source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
seen++;
subscriber.next((lastValue = value));
each > 0 && startTimer(each);
}, undefined, undefined, function () {
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
originalSourceSubscription = source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
}
lastValue = null;
seen++;
destination.next((lastValue = value));
each > 0 && startTimer(each);
},
finalize: function () {
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
}
lastValue = null;
},
}));

@@ -67,4 +88,4 @@ !seen && startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each);

function timeoutErrorFactory(info) {
throw new exports.TimeoutError(info);
throw new TimeoutError(info);
}
//# sourceMappingURL=timeout.js.map

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

var Subject_1 = require("../Subject");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var noop_1 = require("../util/noop");

@@ -12,17 +12,27 @@ var from_1 = require("../observable/from");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var windowSubject = new Subject_1.Subject();
subscriber.next(windowSubject.asObservable());
destination.next(windowSubject.asObservable());
var errorHandler = function (err) {
windowSubject.error(err);
subscriber.error(err);
destination.error(err);
};
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value); }, function () {
windowSubject.complete();
subscriber.complete();
}, errorHandler));
(0, from_1.from)(windowBoundaries).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function () {
windowSubject.complete();
subscriber.next((windowSubject = new Subject_1.Subject()));
}, noop_1.noop, errorHandler));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) { return windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value); },
complete: function () {
windowSubject.complete();
destination.complete();
},
error: errorHandler,
}));
(0, from_1.from)(windowBoundaries).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function () {
windowSubject.complete();
destination.next((windowSubject = new Subject_1.Subject()));
},
complete: noop_1.noop,
error: errorHandler,
}));
return function () {

@@ -29,0 +39,0 @@ windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe();

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

var Subject_1 = require("../Subject");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
function windowCount(windowSize, startWindowEvery) {

@@ -23,44 +23,50 @@ if (startWindowEvery === void 0) { startWindowEvery = 0; }

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var windows = [new Subject_1.Subject()];
var starts = [];
var count = 0;
subscriber.next(windows[0].asObservable());
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var e_1, _a;
try {
for (var windows_1 = __values(windows), windows_1_1 = windows_1.next(); !windows_1_1.done; windows_1_1 = windows_1.next()) {
var window_1 = windows_1_1.value;
window_1.next(value);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
destination.next(windows[0].asObservable());
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var e_1, _a;
try {
if (windows_1_1 && !windows_1_1.done && (_a = windows_1.return)) _a.call(windows_1);
for (var windows_1 = __values(windows), windows_1_1 = windows_1.next(); !windows_1_1.done; windows_1_1 = windows_1.next()) {
var window_1 = windows_1_1.value;
window_1.next(value);
}
}
finally { if (e_1) throw e_1.error; }
}
var c = count - windowSize + 1;
if (c >= 0 && c % startEvery === 0) {
windows.shift().complete();
}
if (++count % startEvery === 0) {
var window_2 = new Subject_1.Subject();
windows.push(window_2);
subscriber.next(window_2.asObservable());
}
}, function () {
while (windows.length > 0) {
windows.shift().complete();
}
subscriber.complete();
}, function (err) {
while (windows.length > 0) {
windows.shift().error(err);
}
subscriber.error(err);
}, function () {
starts = null;
windows = null;
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (windows_1_1 && !windows_1_1.done && (_a = windows_1.return)) _a.call(windows_1);
}
finally { if (e_1) throw e_1.error; }
}
var c = count - windowSize + 1;
if (c >= 0 && c % startEvery === 0) {
windows.shift().complete();
}
if (++count % startEvery === 0) {
var window_2 = new Subject_1.Subject();
windows.push(window_2);
destination.next(window_2.asObservable());
}
},
error: function (err) {
while (windows.length > 0) {
windows.shift().error(err);
}
destination.error(err);
},
complete: function () {
while (windows.length > 0) {
windows.shift().complete();
}
destination.complete();
},
finalize: function () {
starts = null;
windows = null;
},
}));

@@ -67,0 +73,0 @@ });

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

var Subscription_1 = require("../Subscription");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var arrRemove_1 = require("../util/arrRemove");

@@ -23,3 +23,3 @@ var args_1 = require("../util/args");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var windowRecords = [];

@@ -37,3 +37,3 @@ var restartOnClose = false;

var subs = new Subscription_1.Subscription();
subscriber.add(subs);
destination.add(subs);
var window_1 = new Subject_1.Subject();

@@ -46,3 +46,3 @@ var record_1 = {

windowRecords.push(record_1);
subscriber.next(window_1.asObservable());
destination.next(window_1.asObservable());
(0, executeSchedule_1.executeSchedule)(subs, scheduler, function () { return closeWindow(record_1); }, windowTimeSpan);

@@ -52,3 +52,3 @@ }

if (windowCreationInterval !== null && windowCreationInterval >= 0) {
(0, executeSchedule_1.executeSchedule)(subscriber, scheduler, startWindow, windowCreationInterval, true);
(0, executeSchedule_1.executeSchedule)(destination, scheduler, startWindow, windowCreationInterval, true);
}

@@ -65,11 +65,16 @@ else {

});
cb(subscriber);
subscriber.unsubscribe();
cb(destination);
destination.unsubscribe();
};
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
loop(function (record) {
record.window.next(value);
maxWindowSize <= ++record.seen && closeWindow(record);
});
}, function () { return terminate(function (consumer) { return consumer.complete(); }); }, function (err) { return terminate(function (consumer) { return consumer.error(err); }); }));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
loop(function (record) {
record.window.next(value);
maxWindowSize <= ++record.seen && closeWindow(record);
});
},
error: function (err) { return terminate(function (consumer) { return consumer.error(err); }); },
complete: function () { return terminate(function (consumer) { return consumer.complete(); }); },
}));
return function () {

@@ -76,0 +81,0 @@ windowRecords = null;

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

var from_1 = require("../observable/from");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var noop_1 = require("../util/noop");

@@ -25,3 +25,3 @@ var arrRemove_1 = require("../util/arrRemove");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var windows = [];

@@ -32,49 +32,64 @@ var handleError = function (err) {

}
subscriber.error(err);
destination.error(err);
};
(0, from_1.from)(openings).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (openValue) {
var window = new Subject_1.Subject();
windows.push(window);
var closingSubscription = new Subscription_1.Subscription();
var closeWindow = function () {
(0, arrRemove_1.arrRemove)(windows, window);
window.complete();
closingSubscription.unsubscribe();
};
var closingNotifier;
try {
closingNotifier = (0, from_1.from)(closingSelector(openValue));
}
catch (err) {
handleError(err);
return;
}
subscriber.next(window);
closingSubscription.add(closingNotifier.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, closeWindow, noop_1.noop, handleError)));
}, noop_1.noop));
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
var e_1, _a;
var windowsCopy = windows.slice();
try {
for (var windowsCopy_1 = __values(windowsCopy), windowsCopy_1_1 = windowsCopy_1.next(); !windowsCopy_1_1.done; windowsCopy_1_1 = windowsCopy_1.next()) {
var window_1 = windowsCopy_1_1.value;
window_1.next(value);
(0, from_1.from)(openings).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (openValue) {
var window = new Subject_1.Subject();
windows.push(window);
var closingSubscription = new Subscription_1.Subscription();
var closeWindow = function () {
(0, arrRemove_1.arrRemove)(windows, window);
window.complete();
closingSubscription.unsubscribe();
};
var closingNotifier;
try {
closingNotifier = (0, from_1.from)(closingSelector(openValue));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
catch (err) {
handleError(err);
return;
}
destination.next(window);
closingSubscription.add(closingNotifier.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: closeWindow,
error: handleError,
complete: noop_1.noop,
})));
},
complete: noop_1.noop,
}));
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
var e_1, _a;
var windowsCopy = windows.slice();
try {
if (windowsCopy_1_1 && !windowsCopy_1_1.done && (_a = windowsCopy_1.return)) _a.call(windowsCopy_1);
for (var windowsCopy_1 = __values(windowsCopy), windowsCopy_1_1 = windowsCopy_1.next(); !windowsCopy_1_1.done; windowsCopy_1_1 = windowsCopy_1.next()) {
var window_1 = windowsCopy_1_1.value;
window_1.next(value);
}
}
finally { if (e_1) throw e_1.error; }
}
}, function () {
while (0 < windows.length) {
windows.shift().complete();
}
subscriber.complete();
}, handleError, function () {
while (0 < windows.length) {
windows.shift().unsubscribe();
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (windowsCopy_1_1 && !windowsCopy_1_1.done && (_a = windowsCopy_1.return)) _a.call(windowsCopy_1);
}
finally { if (e_1) throw e_1.error; }
}
},
error: handleError,
complete: function () {
while (0 < windows.length) {
windows.shift().complete();
}
destination.complete();
},
finalize: function () {
while (0 < windows.length) {
windows.shift().unsubscribe();
}
},
}));

@@ -81,0 +96,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.windowWhen = void 0;
var Subscriber_1 = require("../Subscriber");
var Observable_1 = require("../Observable");
var Subject_1 = require("../Subject");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var from_1 = require("../observable/from");

@@ -11,3 +11,3 @@ var noop_1 = require("../util/noop");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var window;

@@ -17,3 +17,3 @@ var closingSubscriber;

window.error(err);
subscriber.error(err);
destination.error(err);
};

@@ -24,3 +24,3 @@ var openWindow = function () {

window = new Subject_1.Subject();
subscriber.next(window.asObservable());
destination.next(window.asObservable());
var closingNotifier;

@@ -34,11 +34,22 @@ try {

}
closingNotifier.subscribe((closingSubscriber = (0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, openWindow, noop_1.noop, handleError)));
closingNotifier.subscribe((closingSubscriber = (0, Subscriber_1.operate)({
destination: destination,
next: openWindow,
error: handleError,
complete: noop_1.noop,
})));
};
openWindow();
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) { return window.next(value); }, function () {
window.complete();
subscriber.complete();
}, handleError, function () {
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe();
window = null;
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) { return window.next(value); },
error: handleError,
complete: function () {
window.complete();
destination.complete();
},
finalize: function () {
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe();
window = null;
},
}));

@@ -45,0 +56,0 @@ });

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

var Observable_1 = require("../Observable");
var OperatorSubscriber_1 = require("./OperatorSubscriber");
var Subscriber_1 = require("../Subscriber");
var from_1 = require("../observable/from");

@@ -43,3 +43,3 @@ var identity_1 = require("../util/identity");

return function (source) {
return new Observable_1.Observable(function (subscriber) {
return new Observable_1.Observable(function (destination) {
var len = inputs.length;

@@ -50,9 +50,13 @@ var otherValues = new Array(len);

var _loop_1 = function (i) {
(0, from_1.from)(inputs[i]).subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
otherValues[i] = value;
if (!ready && !hasValue[i]) {
hasValue[i] = true;
(ready = hasValue.every(identity_1.identity)) && (hasValue = null);
}
}, noop_1.noop));
(0, from_1.from)(inputs[i]).subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
otherValues[i] = value;
if (!ready && !hasValue[i]) {
hasValue[i] = true;
(ready = hasValue.every(identity_1.identity)) && (hasValue = null);
}
},
complete: noop_1.noop,
}));
};

@@ -62,7 +66,10 @@ for (var i = 0; i < len; i++) {

}
source.subscribe((0, OperatorSubscriber_1.createOperatorSubscriber)(subscriber, function (value) {
if (ready) {
var values = __spreadArray([value], __read(otherValues), false);
subscriber.next(project ? project.apply(void 0, __spreadArray([], __read(values), false)) : values);
}
source.subscribe((0, Subscriber_1.operate)({
destination: destination,
next: function (value) {
if (ready) {
var values = __spreadArray([value], __read(otherValues), false);
destination.next(project ? project.apply(void 0, __spreadArray([], __read(values), false)) : values);
}
},
}));

@@ -69,0 +76,0 @@ });

@@ -17,4 +17,15 @@ "use strict";

})();
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subscriber = void 0;
exports.operate = exports.Subscriber = void 0;
var isFunction_1 = require("./util/isFunction");

@@ -28,6 +39,19 @@ var Subscription_1 = require("./Subscription");

__extends(Subscriber, _super);
function Subscriber(destination) {
var _this = _super.call(this) || this;
function Subscriber(destination, overrides) {
var _this = this;
var _a, _b, _c, _d;
_this = _super.call(this) || this;
_this.isStopped = false;
_this._nextOverride = null;
_this._errorOverride = null;
_this._completeOverride = null;
_this._onFinalize = null;
_this.destination = destination instanceof Subscriber ? destination : createSafeObserver(destination);
_this._nextOverride = (_a = overrides === null || overrides === void 0 ? void 0 : overrides.next) !== null && _a !== void 0 ? _a : null;
_this._errorOverride = (_b = overrides === null || overrides === void 0 ? void 0 : overrides.error) !== null && _b !== void 0 ? _b : null;
_this._completeOverride = (_c = overrides === null || overrides === void 0 ? void 0 : overrides.complete) !== null && _c !== void 0 ? _c : null;
_this._onFinalize = (_d = overrides === null || overrides === void 0 ? void 0 : overrides.finalize) !== null && _d !== void 0 ? _d : null;
_this._next = _this._nextOverride ? overrideNext : _this._next;
_this._error = _this._errorOverride ? overrideError : _this._error;
_this._complete = _this._completeOverride ? overrideComplete : _this._complete;
if (hasAddAndUnsubscribe(destination)) {

@@ -65,6 +89,7 @@ destination.add(_this);

Subscriber.prototype.unsubscribe = function () {
var _a;
if (!this.closed) {
this.isStopped = true;
_super.prototype.unsubscribe.call(this);
this.destination = null;
(_a = this._onFinalize) === null || _a === void 0 ? void 0 : _a.call(this);
}

@@ -94,2 +119,32 @@ };

exports.Subscriber = Subscriber;
function overrideNext(value) {
try {
this._nextOverride(value);
}
catch (error) {
this.destination.error(error);
}
}
function overrideError(err) {
try {
this._errorOverride(err);
}
catch (error) {
this.destination.error(error);
}
finally {
this.unsubscribe();
}
}
function overrideComplete() {
try {
this._completeOverride();
}
catch (error) {
this.destination.error(error);
}
finally {
this.unsubscribe();
}
}
var ConsumerObserver = (function () {

@@ -147,2 +202,7 @@ function ConsumerObserver(partialObserver) {

}
function operate(_a) {
var destination = _a.destination, subscriberOverrides = __rest(_a, ["destination"]);
return new Subscriber(destination, subscriberOverrides);
}
exports.operate = operate;
//# sourceMappingURL=Subscriber.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArgumentOutOfRangeError = void 0;
var createErrorClass_1 = require("./createErrorClass");
exports.ArgumentOutOfRangeError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function ArgumentOutOfRangeErrorImpl() {
_super(this);
this.name = 'ArgumentOutOfRangeError';
this.message = 'argument out of range';
};
});
var ArgumentOutOfRangeError = (function (_super) {
__extends(ArgumentOutOfRangeError, _super);
function ArgumentOutOfRangeError() {
var _this = _super.call(this, 'argument out of range') || this;
_this.name = 'ArgumentOutOfRangeError';
return _this;
}
return ArgumentOutOfRangeError;
}(Error));
exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
//# sourceMappingURL=ArgumentOutOfRangeError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyError = void 0;
var createErrorClass_1 = require("./createErrorClass");
exports.EmptyError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function EmptyErrorImpl() {
_super(this);
this.name = 'EmptyError';
this.message = 'no elements in sequence';
};
});
var EmptyError = (function (_super) {
__extends(EmptyError, _super);
function EmptyError() {
var _this = _super.call(this, 'no elements in sequence') || this;
_this.name = 'EmptyError';
return _this;
}
return EmptyError;
}(Error));
exports.EmptyError = EmptyError;
//# sourceMappingURL=EmptyError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotFoundError = void 0;
var createErrorClass_1 = require("./createErrorClass");
exports.NotFoundError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function NotFoundErrorImpl(message) {
_super(this);
this.name = 'NotFoundError';
this.message = message;
};
});
var NotFoundError = (function (_super) {
__extends(NotFoundError, _super);
function NotFoundError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'NotFoundError';
return _this;
}
return NotFoundError;
}(Error));
exports.NotFoundError = NotFoundError;
//# sourceMappingURL=NotFoundError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SequenceError = void 0;
var createErrorClass_1 = require("./createErrorClass");
exports.SequenceError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function SequenceErrorImpl(message) {
_super(this);
this.name = 'SequenceError';
this.message = message;
};
});
var SequenceError = (function (_super) {
__extends(SequenceError, _super);
function SequenceError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'SequenceError';
return _this;
}
return SequenceError;
}(Error));
exports.SequenceError = SequenceError;
//# sourceMappingURL=SequenceError.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnsubscriptionError = void 0;
var createErrorClass_1 = require("./createErrorClass");
exports.UnsubscriptionError = (0, createErrorClass_1.createErrorClass)(function (_super) {
return function UnsubscriptionErrorImpl(errors) {
_super(this);
this.message = errors
var UnsubscriptionError = (function (_super) {
__extends(UnsubscriptionError, _super);
function UnsubscriptionError(errors) {
var _this = _super.call(this, errors
? "".concat(errors.length, " errors occurred during unsubscription:\n").concat(errors.map(function (err, i) { return "".concat(i + 1, ") ").concat(err.toString()); }).join('\n '))
: '';
this.name = 'UnsubscriptionError';
this.errors = errors;
};
});
: '') || this;
_this.errors = errors;
_this.name = 'UnsubscriptionError';
return _this;
}
return UnsubscriptionError;
}(Error));
exports.UnsubscriptionError = UnsubscriptionError;
//# sourceMappingURL=UnsubscriptionError.js.map

@@ -16,2 +16,3 @@ export { Observable } from './internal/Observable';

export { Subscriber } from './internal/Subscriber';
export { rx } from './internal/util/rx';
export { pipe } from './internal/util/pipe';

@@ -21,2 +22,3 @@ export { noop } from './internal/util/noop';

export { isObservable } from './internal/util/isObservable';
export { operate } from './internal/Subscriber';
export { lastValueFrom } from './internal/lastValueFrom';

@@ -23,0 +25,0 @@ export { firstValueFrom } from './internal/firstValueFrom';

@@ -52,4 +52,11 @@ import { map } from '../operators/map';

return new Observable((destination) => {
var _a, _b;
const config = Object.assign({ async: true, crossDomain: false, withCredentials: false, method: 'GET', timeout: 0, responseType: 'json' }, init);
const config = {
async: true,
crossDomain: false,
withCredentials: false,
method: 'GET',
timeout: 0,
responseType: 'json',
...init,
};
const { queryParams, body: configuredBody, headers: configuredHeaders } = config;

@@ -90,3 +97,3 @@ let url = config.url;

if ((withCredentials || !crossDomain) && xsrfCookieName && xsrfHeaderName) {
const xsrfCookie = (_b = (_a = document === null || document === void 0 ? void 0 : document.cookie.match(new RegExp(`(^|;\\s*)(${xsrfCookieName})=([^;]*)`))) === null || _a === void 0 ? void 0 : _a.pop()) !== null && _b !== void 0 ? _b : '';
const xsrfCookie = document?.cookie.match(new RegExp(`(^|;\\s*)(${xsrfCookieName})=([^;]*)`))?.pop() ?? '';
if (xsrfCookie) {

@@ -97,5 +104,8 @@ headers[xsrfHeaderName] = xsrfCookie;

const body = extractContentTypeAndMaybeSerializeBody(configuredBody, headers);
const _request = Object.assign(Object.assign({}, config), { url,
const _request = {
...config,
url,
headers,
body });
body,
};
let xhr;

@@ -107,5 +117,4 @@ xhr = init.createXHR ? init.createXHR() : new XMLHttpRequest();

xhr.addEventListener(type, () => {
var _a;
const error = errorFactory();
(_a = progressSubscriber === null || progressSubscriber === void 0 ? void 0 : progressSubscriber.error) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber, error);
progressSubscriber?.error?.(error);
destination.error(error);

@@ -126,3 +135,3 @@ });

if (progressSubscriber) {
[LOADSTART, PROGRESS].forEach((type) => xhr.upload.addEventListener(type, (e) => { var _a; return (_a = progressSubscriber === null || progressSubscriber === void 0 ? void 0 : progressSubscriber.next) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber, e); }));
[LOADSTART, PROGRESS].forEach((type) => xhr.upload.addEventListener(type, (e) => progressSubscriber?.next?.(e)));
}

@@ -137,11 +146,9 @@ if (includeDownloadProgress) {

xhr.addEventListener('error', (e) => {
var _a;
(_a = progressSubscriber === null || progressSubscriber === void 0 ? void 0 : progressSubscriber.error) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber, e);
progressSubscriber?.error?.(e);
emitError();
});
xhr.addEventListener(LOAD, (event) => {
var _a, _b;
const { status } = xhr;
if (status < 400) {
(_a = progressSubscriber === null || progressSubscriber === void 0 ? void 0 : progressSubscriber.complete) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber);
progressSubscriber?.complete?.();
destination.next(createResponse(DOWNLOAD, event));

@@ -151,3 +158,3 @@ destination.complete();

else {
(_b = progressSubscriber === null || progressSubscriber === void 0 ? void 0 : progressSubscriber.error) === null || _b === void 0 ? void 0 : _b.call(progressSubscriber, event);
progressSubscriber?.error?.(event);
emitError(status);

@@ -190,3 +197,2 @@ }

function extractContentTypeAndMaybeSerializeBody(body, headers) {
var _a;
if (!body ||

@@ -206,3 +212,3 @@ typeof body === 'string' ||

if (typeof body === 'object') {
headers['content-type'] = (_a = headers['content-type']) !== null && _a !== void 0 ? _a : 'application/json;charset=utf-8';
headers['content-type'] = headers['content-type'] ?? 'application/json;charset=utf-8';
return JSON.stringify(body);

@@ -209,0 +215,0 @@ }

export class AjaxResponse {
originalEvent;
xhr;
request;
type;
status;
response;
responseType;
loaded;
total;
responseHeaders;
constructor(originalEvent, xhr, request, type = 'download_load') {

@@ -8,4 +18,4 @@ this.originalEvent = originalEvent;

const { status, responseType } = xhr;
this.status = status !== null && status !== void 0 ? status : 0;
this.responseType = responseType !== null && responseType !== void 0 ? responseType : '';
this.status = status ?? 0;
this.responseType = responseType ?? '';
const allHeaders = xhr.getAllResponseHeaders();

@@ -12,0 +22,0 @@ this.responseHeaders = allHeaders

@@ -1,20 +0,23 @@

import { createErrorClass } from '../util/createErrorClass';
export const AjaxError = createErrorClass((_super) => function AjaxErrorImpl(message, xhr, request) {
this.message = message;
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType;
this.response = xhr.response;
});
export const AjaxTimeoutError = (() => {
function AjaxTimeoutErrorImpl(xhr, request) {
AjaxError.call(this, 'ajax timeout', xhr, request);
export class AjaxError extends Error {
xhr;
request;
status;
responseType;
response;
constructor(message, xhr, request) {
super(message);
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType;
this.response = xhr.response;
}
}
export class AjaxTimeoutError extends AjaxError {
constructor(xhr, request) {
super('ajax timeout', xhr, request);
this.name = 'AjaxTimeoutError';
return this;
}
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
return AjaxTimeoutErrorImpl;
})();
}
//# sourceMappingURL=errors.js.map
import { Subject } from './Subject';
export class AsyncSubject extends Subject {
constructor() {
super(...arguments);
this._value = null;
this._hasValue = false;
this._isComplete = false;
}
_value = null;
_hasValue = false;
_isComplete = false;
_checkFinalizedStatuses(subscriber) {

@@ -10,0 +7,0 @@ const { hasError, _hasValue, _value, thrownError, _closed, _isComplete } = this;

import { Subject } from './Subject';
export class BehaviorSubject extends Subject {
_value;
constructor(_value) {

@@ -4,0 +5,0 @@ super();

export function observeNotification(notification, observer) {
var _a, _b, _c;
const { kind, value, error } = notification;

@@ -7,4 +6,4 @@ if (typeof kind !== 'string') {

}
kind === 'N' ? (_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, value) : kind === 'E' ? (_b = observer.error) === null || _b === void 0 ? void 0 : _b.call(observer, error) : (_c = observer.complete) === null || _c === void 0 ? void 0 : _c.call(observer);
kind === 'N' ? observer.next?.(value) : kind === 'E' ? observer.error?.(error) : observer.complete?.();
}
//# sourceMappingURL=Notification.js.map

@@ -103,3 +103,3 @@ import { Subscriber } from './Subscriber';

throw: (err) => {
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
subscription?.unsubscribe();
handleError(err);

@@ -109,3 +109,3 @@ return Promise.reject(err);

return: () => {
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
subscription?.unsubscribe();
handleComplete();

@@ -112,0 +112,0 @@ return Promise.resolve({ value: undefined, done: true });

import { Observable } from '../Observable';
import { arrayOrObject } from '../util/argsArgArrayOrObject';
import { operate } from '../Subscriber';
import { identity } from '../util/identity';
import { createObject } from '../util/createObject';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { EMPTY } from './empty';

@@ -24,3 +24,3 @@ import { from } from './from';

export function combineLatestInit(observables, valueTransform = identity) {
return (subscriber) => {
return (destination) => {
const { length } = observables;

@@ -33,15 +33,19 @@ const values = new Array(length);

let hasFirstValue = false;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
values[i] = value;
if (!hasFirstValue) {
hasFirstValue = true;
remainingFirstValues--;
}
if (!remainingFirstValues) {
subscriber.next(valueTransform(Array.from(values)));
}
}, () => {
if (!--active) {
subscriber.complete();
}
source.subscribe(operate({
destination,
next: (value) => {
values[i] = value;
if (!hasFirstValue) {
hasFirstValue = true;
remainingFirstValues--;
}
if (!remainingFirstValues) {
destination.next(valueTransform(Array.from(values)));
}
},
complete: () => {
if (!--active) {
destination.complete();
}
},
}));

@@ -48,0 +52,0 @@ }

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

import { __rest } from "tslib";
import { createOperatorSubscriber } from '../../operators/OperatorSubscriber';
import { operate } from '../../Subscriber';
import { Observable } from '../../Observable';
import { from } from '../from';
export function fromFetch(input, initWithSelector = {}) {
const { selector } = initWithSelector, init = __rest(initWithSelector, ["selector"]);
return new Observable((subscriber) => {
const { selector, ...init } = initWithSelector;
return new Observable((destination) => {
const controller = new AbortController();

@@ -23,9 +22,9 @@ const { signal } = controller;

outerSignal.addEventListener('abort', outerSignalHandler);
subscriber.add(() => outerSignal.removeEventListener('abort', outerSignalHandler));
destination.add(() => outerSignal.removeEventListener('abort', outerSignalHandler));
}
}
const perSubscriberInit = Object.assign(Object.assign({}, init), { signal });
const perSubscriberInit = { ...init, signal };
const handleError = (err) => {
abortable = false;
subscriber.error(err);
destination.error(err);
};

@@ -35,11 +34,15 @@ fetch(input, perSubscriberInit)

if (selector) {
from(selector(response)).subscribe(createOperatorSubscriber(subscriber, undefined, () => {
abortable = false;
subscriber.complete();
}, handleError));
from(selector(response)).subscribe(operate({
destination,
complete: () => {
abortable = false;
destination.complete();
},
error: handleError,
}));
}
else {
abortable = false;
subscriber.next(response);
subscriber.complete();
destination.next(response);
destination.complete();
}

@@ -46,0 +49,0 @@ })

@@ -13,5 +13,7 @@ import { Subject, AnonymousSubject } from '../../Subject';

export class WebSocketSubject extends AnonymousSubject {
_config;
_output;
_socket = null;
constructor(urlConfigOrSource, destination) {
super();
this._socket = null;
if (urlConfigOrSource instanceof Observable) {

@@ -22,3 +24,3 @@ this.destination = destination;

else {
const config = (this._config = Object.assign({}, DEFAULT_WEBSOCKET_CONFIG));
const config = (this._config = { ...DEFAULT_WEBSOCKET_CONFIG });
this._output = new Subject();

@@ -25,0 +27,0 @@ if (typeof urlConfigOrSource === 'string') {

@@ -5,12 +5,13 @@ import { Observable } from '../Observable';

import { popResultSelector } from '../util/args';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
import { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';
import { createObject } from '../util/createObject';
import { EmptyError } from '../util/EmptyError';
export function forkJoin(...args) {
const resultSelector = popResultSelector(args);
const { args: sources, keys } = argsArgArrayOrObject(args);
const result = new Observable((subscriber) => {
const result = new Observable((destination) => {
const { length } = sources;
if (!length) {
subscriber.complete();
destination.complete();
return;

@@ -23,15 +24,23 @@ }

let hasValue = false;
from(sources[sourceIndex]).subscribe(createOperatorSubscriber(subscriber, (value) => {
if (!hasValue) {
hasValue = true;
remainingEmissions--;
}
values[sourceIndex] = value;
}, () => remainingCompletions--, undefined, () => {
if (!remainingCompletions || !hasValue) {
if (!remainingEmissions) {
subscriber.next(keys ? createObject(keys, values) : values);
from(sources[sourceIndex]).subscribe(operate({
destination,
next: (value) => {
if (!hasValue) {
hasValue = true;
remainingEmissions--;
}
subscriber.complete();
}
values[sourceIndex] = value;
},
complete: () => remainingCompletions--,
finalize: () => {
if (!remainingCompletions || !hasValue) {
if (remainingEmissions === 0) {
destination.next(keys ? createObject(keys, values) : values);
destination.complete();
}
else {
destination.error(new EmptyError());
}
}
},
}));

@@ -38,0 +47,0 @@ }

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

import { __asyncValues, __awaiter } from "tslib";
import { isArrayLike } from '../util/isArrayLike';

@@ -53,3 +52,3 @@ import { isPromise } from '../util/isPromise';

}
function fromPromise(promise) {
export function fromPromise(promise) {
return new Observable((subscriber) => {

@@ -85,35 +84,17 @@ promise

}
function process(asyncIterable, subscriber) {
var _a, asyncIterable_1, asyncIterable_1_1;
var _b, e_1, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
try {
for (_a = true, asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), _b = asyncIterable_1_1.done, !_b;) {
_d = asyncIterable_1_1.value;
_a = false;
try {
const value = _d;
subscriber.next(value);
if (subscriber.closed) {
return;
}
}
finally {
_a = true;
}
}
async function process(asyncIterable, subscriber) {
for await (const value of asyncIterable) {
subscriber.next(value);
if (subscriber.closed) {
return;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_a && !_b && (_c = asyncIterable_1.return)) yield _c.call(asyncIterable_1);
}
finally { if (e_1) throw e_1.error; }
}
subscriber.complete();
});
}
subscriber.complete();
}
export function subscribeToArray(array, subscriber) {
const length = array.length;
for (let i = 0; i < length && !subscriber.closed; i++) {
for (let i = 0; i < length; i++) {
if (subscriber.closed) {
return;
}
subscriber.next(array[i]);

@@ -120,0 +101,0 @@ }

import { Observable } from '../Observable';
import { argsOrArgArray } from '../util/argsOrArgArray';
import { OperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';

@@ -8,3 +8,3 @@ import { from } from './from';

const nextSources = argsOrArgArray(sources);
return new Observable((subscriber) => {
return new Observable((destination) => {
let sourceIndex = 0;

@@ -21,3 +21,3 @@ const subscribeNext = () => {

}
const innerSubscriber = new OperatorSubscriber(subscriber, undefined, noop, noop);
const innerSubscriber = operate({ destination, error: noop, complete: noop });
nextSource.subscribe(innerSubscriber);

@@ -27,3 +27,3 @@ innerSubscriber.add(subscribeNext);

else {
subscriber.complete();
destination.complete();
}

@@ -30,0 +30,0 @@ };

import { Observable } from '../Observable';
import { from } from './from';
import { argsOrArgArray } from '../util/argsOrArgArray';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
export function race(...sources) {

@@ -10,13 +10,16 @@ sources = argsOrArgArray(sources);

export function raceInit(sources) {
return (subscriber) => {
return (destination) => {
let subscriptions = [];
for (let i = 0; subscriptions && !subscriber.closed && i < sources.length; i++) {
subscriptions.push(from(sources[i]).subscribe(createOperatorSubscriber(subscriber, (value) => {
if (subscriptions) {
for (let s = 0; s < subscriptions.length; s++) {
s !== i && subscriptions[s].unsubscribe();
for (let i = 0; subscriptions && !destination.closed && i < sources.length; i++) {
subscriptions.push(from(sources[i]).subscribe(operate({
destination,
next: (value) => {
if (subscriptions) {
for (let s = 0; s < subscriptions.length; s++) {
s !== i && subscriptions[s].unsubscribe();
}
subscriptions = null;
}
subscriptions = null;
}
subscriber.next(value);
destination.next(value);
},
})));

@@ -23,0 +26,0 @@ }

@@ -5,3 +5,3 @@ import { Observable } from '../Observable';

import { EMPTY } from './empty';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
import { popResultSelector } from '../util/args';

@@ -12,21 +12,25 @@ export function zip(...args) {

return sources.length
? new Observable((subscriber) => {
? new Observable((destination) => {
let buffers = sources.map(() => []);
let completed = sources.map(() => false);
subscriber.add(() => {
destination.add(() => {
buffers = completed = null;
});
for (let sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {
from(sources[sourceIndex]).subscribe(createOperatorSubscriber(subscriber, (value) => {
buffers[sourceIndex].push(value);
if (buffers.every((buffer) => buffer.length)) {
const result = buffers.map((buffer) => buffer.shift());
subscriber.next(resultSelector ? resultSelector(...result) : result);
if (buffers.some((buffer, i) => !buffer.length && completed[i])) {
subscriber.complete();
for (let sourceIndex = 0; !destination.closed && sourceIndex < sources.length; sourceIndex++) {
from(sources[sourceIndex]).subscribe(operate({
destination,
next: (value) => {
buffers[sourceIndex].push(value);
if (buffers.every((buffer) => buffer.length)) {
const result = buffers.map((buffer) => buffer.shift());
destination.next(resultSelector ? resultSelector(...result) : result);
if (buffers.some((buffer, i) => !buffer.length && completed[i])) {
destination.complete();
}
}
}
}, () => {
completed[sourceIndex] = true;
!buffers[sourceIndex].length && subscriber.complete();
},
complete: () => {
completed[sourceIndex] = true;
!buffers[sourceIndex].length && destination.complete();
},
}));

@@ -33,0 +37,0 @@ }

@@ -0,6 +1,6 @@

import { operate } from '../Subscriber';
import { Observable } from '../Observable';
import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function audit(durationSelector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let hasValue = false;

@@ -11,3 +11,3 @@ let lastValue = null;

const endDuration = () => {
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
durationSubscriber?.unsubscribe();
durationSubscriber = null;

@@ -18,19 +18,27 @@ if (hasValue) {

lastValue = null;
subscriber.next(value);
destination.next(value);
}
isComplete && subscriber.complete();
isComplete && destination.complete();
};
const cleanupDuration = () => {
durationSubscriber = null;
isComplete && subscriber.complete();
isComplete && destination.complete();
};
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
lastValue = value;
if (!durationSubscriber) {
from(durationSelector(value)).subscribe((durationSubscriber = createOperatorSubscriber(subscriber, endDuration, cleanupDuration)));
}
}, () => {
isComplete = true;
(!hasValue || !durationSubscriber || durationSubscriber.closed) && subscriber.complete();
source.subscribe(operate({
destination,
next: (value) => {
hasValue = true;
lastValue = value;
if (!durationSubscriber) {
from(durationSelector(value)).subscribe((durationSubscriber = operate({
destination,
next: endDuration,
complete: cleanupDuration,
})));
}
},
complete: () => {
isComplete = true;
(!hasValue || !durationSubscriber || durationSubscriber.closed) && destination.complete();
},
}));

@@ -37,0 +45,0 @@ });

import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';
export function buffer(closingNotifier) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let currentBuffer = [];
from(closingNotifier).subscribe(createOperatorSubscriber(subscriber, () => {
const b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
}, noop));
source.subscribe(createOperatorSubscriber(subscriber, (value) => currentBuffer.push(value), () => {
subscriber.next(currentBuffer);
subscriber.complete();
from(closingNotifier).subscribe(operate({
destination,
next: () => {
const b = currentBuffer;
currentBuffer = [];
destination.next(b);
},
complete: noop,
}));
source.subscribe(operate({
destination,
next: (value) => currentBuffer.push(value),
complete: () => {
destination.next(currentBuffer);
destination.complete();
},
}));
return () => {

@@ -18,0 +26,0 @@ currentBuffer = null;

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { arrRemove } from '../util/arrRemove';
export function bufferCount(bufferSize, startBufferEvery = null) {
startBufferEvery = startBufferEvery !== null && startBufferEvery !== void 0 ? startBufferEvery : bufferSize;
return (source) => new Observable((subscriber) => {
startBufferEvery = startBufferEvery ?? bufferSize;
return (source) => new Observable((destination) => {
let buffers = [];
let count = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
let toEmit = null;
if (count++ % startBufferEvery === 0) {
buffers.push([]);
}
for (const buffer of buffers) {
buffer.push(value);
if (bufferSize <= buffer.length) {
toEmit = toEmit !== null && toEmit !== void 0 ? toEmit : [];
toEmit.push(buffer);
source.subscribe(operate({
destination,
next: (value) => {
let toEmit = null;
if (count++ % startBufferEvery === 0) {
buffers.push([]);
}
}
if (toEmit) {
for (const buffer of toEmit) {
arrRemove(buffers, buffer);
subscriber.next(buffer);
for (const buffer of buffers) {
buffer.push(value);
if (bufferSize <= buffer.length) {
toEmit = toEmit ?? [];
toEmit.push(buffer);
}
}
}
}, () => {
for (const buffer of buffers) {
subscriber.next(buffer);
}
subscriber.complete();
}, undefined, () => {
buffers = null;
if (toEmit) {
for (const buffer of toEmit) {
arrRemove(buffers, buffer);
destination.next(buffer);
}
}
},
complete: () => {
for (const buffer of buffers) {
destination.next(buffer);
}
destination.complete();
},
finalize: () => {
buffers = null;
},
}));

@@ -35,0 +40,0 @@ });

import { Subscription } from '../Subscription';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { arrRemove } from '../util/arrRemove';

@@ -9,7 +9,6 @@ import { asyncScheduler } from '../scheduler/async';

export function bufferTime(bufferTimeSpan, ...otherArgs) {
var _a, _b;
const scheduler = (_a = popScheduler(otherArgs)) !== null && _a !== void 0 ? _a : asyncScheduler;
const bufferCreationInterval = (_b = otherArgs[0]) !== null && _b !== void 0 ? _b : null;
const scheduler = popScheduler(otherArgs) ?? asyncScheduler;
const bufferCreationInterval = otherArgs[0] ?? null;
const maxBufferSize = otherArgs[1] || Infinity;
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let bufferRecords = [];

@@ -21,3 +20,3 @@ let restartOnEmit = false;

arrRemove(bufferRecords, record);
subscriber.next(buffer);
destination.next(buffer);
restartOnEmit && startBuffer();

@@ -28,3 +27,3 @@ };

const subs = new Subscription();
subscriber.add(subs);
destination.add(subs);
const buffer = [];

@@ -40,3 +39,3 @@ const record = {

if (bufferCreationInterval !== null && bufferCreationInterval >= 0) {
executeSchedule(subscriber, scheduler, startBuffer, bufferCreationInterval, true);
executeSchedule(destination, scheduler, startBuffer, bufferCreationInterval, true);
}

@@ -47,17 +46,22 @@ else {

startBuffer();
const bufferTimeSubscriber = createOperatorSubscriber(subscriber, (value) => {
const recordsCopy = bufferRecords.slice();
for (const record of recordsCopy) {
const { buffer } = record;
buffer.push(value);
maxBufferSize <= buffer.length && emit(record);
}
}, () => {
while (bufferRecords === null || bufferRecords === void 0 ? void 0 : bufferRecords.length) {
subscriber.next(bufferRecords.shift().buffer);
}
bufferTimeSubscriber === null || bufferTimeSubscriber === void 0 ? void 0 : bufferTimeSubscriber.unsubscribe();
subscriber.complete();
subscriber.unsubscribe();
}, undefined, () => (bufferRecords = null));
const bufferTimeSubscriber = operate({
destination,
next: (value) => {
const recordsCopy = bufferRecords.slice();
for (const record of recordsCopy) {
const { buffer } = record;
buffer.push(value);
maxBufferSize <= buffer.length && emit(record);
}
},
complete: () => {
while (bufferRecords?.length) {
destination.next(bufferRecords.shift().buffer);
}
bufferTimeSubscriber?.unsubscribe();
destination.complete();
destination.unsubscribe();
},
finalize: () => (bufferRecords = null),
});
source.subscribe(bufferTimeSubscriber);

@@ -64,0 +68,0 @@ });

import { Subscription } from '../Subscription';
import { Observable } from '../Observable';
import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';
import { arrRemove } from '../util/arrRemove';
export function bufferToggle(openings, closingSelector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
const buffers = [];
from(openings).subscribe(createOperatorSubscriber(subscriber, (openValue) => {
const buffer = [];
buffers.push(buffer);
const closingSubscription = new Subscription();
const emitBuffer = () => {
arrRemove(buffers, buffer);
subscriber.next(buffer);
closingSubscription.unsubscribe();
};
closingSubscription.add(from(closingSelector(openValue)).subscribe(createOperatorSubscriber(subscriber, emitBuffer, noop)));
}, noop));
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
for (const buffer of buffers) {
buffer.push(value);
}
}, () => {
while (buffers.length > 0) {
subscriber.next(buffers.shift());
}
subscriber.complete();
from(openings).subscribe(operate({
destination,
next: (openValue) => {
const buffer = [];
buffers.push(buffer);
const closingSubscription = new Subscription();
const emitBuffer = () => {
arrRemove(buffers, buffer);
destination.next(buffer);
closingSubscription.unsubscribe();
};
closingSubscription.add(from(closingSelector(openValue)).subscribe(operate({ destination, next: emitBuffer, complete: noop })));
},
complete: noop,
}));
source.subscribe(operate({
destination,
next: (value) => {
for (const buffer of buffers) {
buffer.push(value);
}
},
complete: () => {
while (buffers.length > 0) {
destination.next(buffers.shift());
}
destination.complete();
},
}));
});
}
//# sourceMappingURL=bufferToggle.js.map

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

import { operate } from '../Subscriber';
import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { from } from '../observable/from';

@@ -10,15 +10,24 @@ export function bufferWhen(closingSelector) {

const openBuffer = () => {
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe();
closingSubscriber?.unsubscribe();
const b = buffer;
buffer = [];
b && subscriber.next(b);
from(closingSelector()).subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openBuffer, noop)));
from(closingSelector()).subscribe((closingSubscriber = operate({
destination: subscriber,
next: openBuffer,
complete: noop,
})));
};
openBuffer();
source.subscribe(createOperatorSubscriber(subscriber, (value) => buffer === null || buffer === void 0 ? void 0 : buffer.push(value), () => {
buffer && subscriber.next(buffer);
subscriber.complete();
}, undefined, () => (buffer = closingSubscriber = null)));
source.subscribe(operate({
destination: subscriber,
next: (value) => buffer?.push(value),
complete: () => {
buffer && subscriber.next(buffer);
subscriber.complete();
},
finalize: () => (buffer = closingSubscriber = null),
}));
});
}
//# sourceMappingURL=bufferWhen.js.map
import { Observable } from '../Observable';
import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function catchError(selector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let innerSub = null;
let syncUnsub = false;
let handledResult;
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, (err) => {
handledResult = from(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(subscriber);
}
else {
syncUnsub = true;
}
innerSub = source.subscribe(operate({
destination,
error: (err) => {
handledResult = from(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(destination);
}
else {
syncUnsub = true;
}
},
}));

@@ -23,3 +26,3 @@ if (syncUnsub) {

innerSub = null;
handledResult.subscribe(subscriber);
handledResult.subscribe(destination);
}

@@ -26,0 +29,0 @@ });

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

import { operate } from '../Subscriber';
import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { from } from '../observable/from';
export function debounce(durationSelector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let hasValue = false;

@@ -11,3 +11,3 @@ let lastValue = null;

const emit = () => {
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
durationSubscriber?.unsubscribe();
durationSubscriber = null;

@@ -18,16 +18,21 @@ if (hasValue) {

lastValue = null;
subscriber.next(value);
destination.next(value);
}
};
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
hasValue = true;
lastValue = value;
durationSubscriber = createOperatorSubscriber(subscriber, emit, noop);
from(durationSelector(value)).subscribe(durationSubscriber);
}, () => {
emit();
subscriber.complete();
}, undefined, () => {
lastValue = durationSubscriber = null;
source.subscribe(operate({
destination,
next: (value) => {
durationSubscriber?.unsubscribe();
hasValue = true;
lastValue = value;
durationSubscriber = operate({ destination, next: emit, complete: noop });
from(durationSelector(value)).subscribe(durationSubscriber);
},
complete: () => {
emit();
destination.complete();
},
finalize: () => {
lastValue = durationSubscriber = null;
},
}));

@@ -34,0 +39,0 @@ });

import { asyncScheduler } from '../scheduler/async';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function debounceTime(dueTime, scheduler = asyncScheduler) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let activeTask = null;

@@ -18,3 +18,3 @@ let lastValue = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}

@@ -27,3 +27,3 @@ };

activeTask = this.schedule(undefined, targetTime - now);
subscriber.add(activeTask);
destination.add(activeTask);
return;

@@ -33,16 +33,21 @@ }

}
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
lastValue = value;
lastTime = scheduler.now();
if (!activeTask) {
scheduling = true;
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
scheduling = false;
subscriber.add(activeTask);
}
}, () => {
emit();
subscriber.complete();
}, undefined, () => {
lastValue = activeTask = null;
source.subscribe(operate({
destination,
next: (value) => {
lastValue = value;
lastTime = scheduler.now();
if (!activeTask) {
scheduling = true;
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
scheduling = false;
destination.add(activeTask);
}
},
complete: () => {
emit();
destination.complete();
},
finalize: () => {
lastValue = activeTask = null;
},
}));

@@ -49,0 +54,0 @@ });

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function defaultIfEmpty(defaultValue) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let hasValue = false;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
subscriber.next(value);
}, () => {
if (!hasValue) {
subscriber.next(defaultValue);
}
subscriber.complete();
source.subscribe(operate({
destination,
next: (value) => {
hasValue = true;
destination.next(value);
},
complete: () => {
if (!hasValue) {
destination.next(defaultValue);
}
destination.complete();
},
}));

@@ -15,0 +19,0 @@ });

import { observeNotification } from '../Notification';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function dematerialize() {
return (source) => new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, (notification) => observeNotification(notification, subscriber)));
return (source) => new Observable((destination) => {
source.subscribe(operate({ destination, next: (notification) => observeNotification(notification, destination) }));
});
}
//# sourceMappingURL=dematerialize.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';
import { from } from '../observable/from';
export function distinct(keySelector, flushes) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
const distinctKeys = new Set();
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
subscriber.next(value);
}
source.subscribe(operate({
destination,
next: (value) => {
const key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
destination.next(value);
}
},
}));
flushes && from(flushes).subscribe(createOperatorSubscriber(subscriber, () => distinctKeys.clear(), noop));
flushes && from(flushes).subscribe(operate({ destination, next: () => distinctKeys.clear(), complete: noop }));
});
}
//# sourceMappingURL=distinct.js.map
import { identity } from '../util/identity';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function distinctUntilChanged(comparator, keySelector = identity) {
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
return (source) => new Observable((subscriber) => {
comparator = comparator ?? defaultCompare;
return (source) => new Observable((destination) => {
let previousKey;
let first = true;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const currentKey = keySelector(value);
if (first || !comparator(previousKey, currentKey)) {
first = false;
previousKey = currentKey;
subscriber.next(value);
}
source.subscribe(operate({
destination,
next: (value) => {
const currentKey = keySelector(value);
if (first || !comparator(previousKey, currentKey)) {
first = false;
previousKey = currentKey;
destination.next(value);
}
},
}));

@@ -17,0 +20,0 @@ });

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

import { Observable } from '../Observable';
import { operate } from '../Subscriber';
import { subscribeToArray } from '../observable/from';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
export function endWith(...values) {
return (source) => new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, undefined, () => {
subscribeToArray(values, subscriber);
return (source) => new Observable((destination) => {
source.subscribe(operate({
destination,
complete: () => {
subscribeToArray(values, destination);
},
}));

@@ -9,0 +12,0 @@ });

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function every(predicate, thisArg) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
if (!predicate.call(thisArg, value, index++, source)) {
subscriber.next(false);
subscriber.complete();
}
}, () => {
subscriber.next(true);
subscriber.complete();
source.subscribe(operate({
destination,
next: (value) => {
if (!predicate.call(thisArg, value, index++, source)) {
destination.next(false);
destination.complete();
}
},
complete: () => {
destination.next(true);
destination.complete();
},
}));

@@ -15,0 +19,0 @@ });

@@ -0,20 +1,27 @@

import { operate } from '../Subscriber';
import { from } from '../observable/from';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function exhaustMap(project) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let index = 0;
let innerSub = null;
let isComplete = false;
source.subscribe(createOperatorSubscriber(subscriber, (outerValue) => {
if (!innerSub) {
innerSub = createOperatorSubscriber(subscriber, undefined, () => {
innerSub = null;
isComplete && subscriber.complete();
});
from(project(outerValue, index++)).subscribe(innerSub);
}
}, () => {
isComplete = true;
!innerSub && subscriber.complete();
source.subscribe(operate({
destination,
next: (outerValue) => {
if (!innerSub) {
innerSub = operate({
destination,
complete: () => {
innerSub = null;
isComplete && destination.complete();
},
});
from(project(outerValue, index++)).subscribe(innerSub);
}
},
complete: () => {
isComplete = true;
!innerSub && destination.complete();
},
}));

@@ -21,0 +28,0 @@ });

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function filter(predicate, thisArg) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => predicate.call(thisArg, value, index++) && subscriber.next(value)));
source.subscribe(operate({ destination, next: (value) => predicate.call(thisArg, value, index++) && destination.next(value) }));
});
}
//# sourceMappingURL=filter.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function find(predicate) {
return (source) => new Observable((subscriber) => createFind(predicate, 'value', source, subscriber));
}
export function createFind(predicate, emit, source, subscriber) {
export function createFind(predicate, emit, source, destination) {
const findIndex = emit === 'index';
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const i = index++;
if (predicate(value, i, source)) {
subscriber.next(findIndex ? i : value);
subscriber.complete();
}
}, () => {
subscriber.next(findIndex ? -1 : undefined);
subscriber.complete();
source.subscribe(operate({
destination,
next: (value) => {
const i = index++;
if (predicate(value, i, source)) {
destination.next(findIndex ? i : value);
destination.complete();
}
},
complete: () => {
destination.next(findIndex ? -1 : undefined);
destination.complete();
},
}));
}
//# sourceMappingURL=find.js.map
import { Observable } from '../Observable';
import { from } from '../observable/from';
import { Subject } from '../Subject';
import { createOperatorSubscriber, OperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function groupBy(keySelector, elementOrOptions, duration, connector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let element;

@@ -17,42 +17,40 @@ if (!elementOrOptions || typeof elementOrOptions === 'function') {

groups.forEach(cb);
cb(subscriber);
cb(destination);
};
const handleError = (err) => notify((consumer) => consumer.error(err));
let activeGroups = 0;
let teardownAttempted = false;
const groupBySourceSubscriber = new OperatorSubscriber(subscriber, (value) => {
try {
const key = keySelector(value);
let group = groups.get(key);
if (!group) {
groups.set(key, (group = connector ? connector() : new Subject()));
const grouped = createGroupedObservable(key, group);
subscriber.next(grouped);
if (duration) {
const durationSubscriber = createOperatorSubscriber(group, () => {
group.complete();
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
}, undefined, undefined, () => groups.delete(key));
groupBySourceSubscriber.add(from(duration(grouped)).subscribe(durationSubscriber));
const groupBySourceSubscriber = operate({
destination,
next: (value) => {
try {
const key = keySelector(value);
let group = groups.get(key);
if (!group) {
groups.set(key, (group = connector ? connector() : new Subject()));
const grouped = createGroupedObservable(key, group);
destination.next(grouped);
if (duration) {
const durationSubscriber = operate({
destination: group,
next: () => {
group.complete();
durationSubscriber?.unsubscribe();
},
finalize: () => groups.delete(key),
});
groupBySourceSubscriber.add(from(duration(grouped)).subscribe(durationSubscriber));
}
}
group.next(element ? element(value) : value);
}
group.next(element ? element(value) : value);
}
catch (err) {
handleError(err);
}
}, () => notify((consumer) => consumer.complete()), handleError, () => groups.clear(), () => {
teardownAttempted = true;
return activeGroups === 0;
catch (err) {
handleError(err);
}
},
error: handleError,
complete: () => notify((consumer) => consumer.complete()),
finalize: () => groups.clear(),
});
source.subscribe(groupBySourceSubscriber);
function createGroupedObservable(key, groupSubject) {
const result = new Observable((groupSubscriber) => {
activeGroups++;
const innerSub = groupSubject.subscribe(groupSubscriber);
return () => {
innerSub.unsubscribe();
--activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe();
};
});
const result = new Observable((groupSubscriber) => groupSubject.subscribe(groupSubscriber));
result.key = key;

@@ -59,0 +57,0 @@ return result;

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';
export function ignoreElements() {
return (source) => new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, noop));
return (source) => new Observable((destination) => {
source.subscribe(operate({ destination, next: noop }));
});
}
//# sourceMappingURL=ignoreElements.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function isEmpty() {
return (source) => new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, () => {
subscriber.next(false);
subscriber.complete();
}, () => {
subscriber.next(true);
subscriber.complete();
return (source) => new Observable((destination) => {
source.subscribe(operate({
destination,
next: () => {
destination.next(false);
destination.complete();
},
complete: () => {
destination.next(true);
destination.complete();
},
}));

@@ -12,0 +16,0 @@ });

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function map(project) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
subscriber.next(project(value, index++));
source.subscribe(operate({
destination,
next: (value) => {
destination.next(project(value, index++));
},
}));

@@ -9,0 +12,0 @@ });

import { COMPLETE_NOTIFICATION, errorNotification, nextNotification } from '../NotificationFactories';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function materialize() {
return (source) => new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
subscriber.next(nextNotification(value));
}, () => {
subscriber.next(COMPLETE_NOTIFICATION);
subscriber.complete();
}, (error) => {
subscriber.next(errorNotification(error));
subscriber.complete();
return (source) => new Observable((destination) => {
source.subscribe(operate({
destination,
next: (value) => {
destination.next(nextNotification(value));
},
error: (error) => {
destination.next(errorNotification(error));
destination.complete();
},
complete: () => {
destination.next(COMPLETE_NOTIFICATION);
destination.complete();
},
}));

@@ -15,0 +20,0 @@ });

import { from } from '../observable/from';
import { operate } from '../Subscriber';
import { executeSchedule } from '../util/executeSchedule';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
export function mergeInternals(source, destination, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
const buffer = [];

@@ -11,3 +11,3 @@ let active = 0;

if (isComplete && !buffer.length && !active) {
subscriber.complete();
destination.complete();
}

@@ -17,44 +17,53 @@ };

const doInnerSub = (value) => {
expand && subscriber.next(value);
expand && destination.next(value);
active++;
let innerComplete = false;
from(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, (innerValue) => {
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
if (expand) {
outerNext(innerValue);
}
else {
subscriber.next(innerValue);
}
}, () => {
innerComplete = true;
}, undefined, () => {
if (innerComplete) {
try {
active--;
while (buffer.length && active < concurrent) {
const bufferedValue = buffer.shift();
if (innerSubScheduler) {
executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));
from(project(value, index++)).subscribe(operate({
destination,
next: (innerValue) => {
onBeforeNext?.(innerValue);
if (expand) {
outerNext(innerValue);
}
else {
destination.next(innerValue);
}
},
complete: () => {
innerComplete = true;
},
finalize: () => {
if (innerComplete) {
try {
active--;
while (buffer.length && active < concurrent) {
const bufferedValue = buffer.shift();
if (innerSubScheduler) {
executeSchedule(destination, innerSubScheduler, () => doInnerSub(bufferedValue));
}
else {
doInnerSub(bufferedValue);
}
}
else {
doInnerSub(bufferedValue);
}
checkComplete();
}
checkComplete();
catch (err) {
destination.error(err);
}
}
catch (err) {
subscriber.error(err);
}
}
},
}));
};
source.subscribe(createOperatorSubscriber(subscriber, outerNext, () => {
isComplete = true;
checkComplete();
source.subscribe(operate({
destination,
next: outerNext,
complete: () => {
isComplete = true;
checkComplete();
},
}));
return () => {
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
additionalFinalizer?.();
};
}
//# sourceMappingURL=mergeInternals.js.map
import { executeSchedule } from '../util/executeSchedule';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function observeOn(scheduler, delay = 0) {
return (source) => new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay), () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay), (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)));
return (source) => new Observable((destination) => {
source.subscribe(operate({
destination,
next: (value) => executeSchedule(destination, scheduler, () => destination.next(value), delay),
error: (err) => executeSchedule(destination, scheduler, () => destination.error(err), delay),
complete: () => executeSchedule(destination, scheduler, () => destination.complete(), delay),
}));
});
}
//# sourceMappingURL=observeOn.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function pairwise() {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let prev;
let hasPrev = false;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const p = prev;
prev = value;
hasPrev && subscriber.next([p, value]);
hasPrev = true;
source.subscribe(operate({
destination,
next: (value) => {
const p = prev;
prev = value;
hasPrev && destination.next([p, value]);
hasPrev = true;
},
}));

@@ -13,0 +16,0 @@ });

import { EMPTY } from '../observable/empty';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -19,13 +19,16 @@ import { timer } from '../observable/timer';

? () => EMPTY
: (source) => new Observable((subscriber) => {
: (source) => new Observable((destination) => {
let soFar = 0;
let sourceSub;
const resubscribe = () => {
sourceSub === null || sourceSub === void 0 ? void 0 : sourceSub.unsubscribe();
sourceSub?.unsubscribe();
sourceSub = null;
if (delay != null) {
const notifier = typeof delay === 'number' ? timer(delay) : from(delay(soFar));
const notifierSubscriber = createOperatorSubscriber(subscriber, () => {
notifierSubscriber.unsubscribe();
subscribeToSource();
const notifierSubscriber = operate({
destination,
next: () => {
notifierSubscriber.unsubscribe();
subscribeToSource();
},
});

@@ -40,14 +43,17 @@ notifier.subscribe(notifierSubscriber);

let syncUnsub = false;
sourceSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, () => {
if (++soFar < count) {
if (sourceSub) {
resubscribe();
sourceSub = source.subscribe(operate({
destination,
complete: () => {
if (++soFar < count) {
if (sourceSub) {
resubscribe();
}
else {
syncUnsub = true;
}
}
else {
syncUnsub = true;
destination.complete();
}
}
else {
subscriber.complete();
}
},
}));

@@ -54,0 +60,0 @@ if (syncUnsub) {

import { Observable } from '../Observable';
import { from } from '../observable/from';
import { Subject } from '../Subject';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function repeatWhen(notifier) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let innerSub;

@@ -12,16 +12,20 @@ let syncResub = false;

let isMainComplete = false;
const checkComplete = () => isMainComplete && isNotifierComplete && (subscriber.complete(), true);
const checkComplete = () => isMainComplete && isNotifierComplete && (destination.complete(), true);
const getCompletionSubject = () => {
if (!completions$) {
completions$ = new Subject();
from(notifier(completions$)).subscribe(createOperatorSubscriber(subscriber, () => {
if (innerSub) {
subscribeForRepeatWhen();
}
else {
syncResub = true;
}
}, () => {
isNotifierComplete = true;
checkComplete();
from(notifier(completions$)).subscribe(operate({
destination,
next: () => {
if (innerSub) {
subscribeForRepeatWhen();
}
else {
syncResub = true;
}
},
complete: () => {
isNotifierComplete = true;
checkComplete();
},
}));

@@ -33,5 +37,8 @@ }

isMainComplete = false;
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, () => {
isMainComplete = true;
!checkComplete() && getCompletionSubject().next();
innerSub = source.subscribe(operate({
destination,
complete: () => {
isMainComplete = true;
!checkComplete() && getCompletionSubject().next();
},
}));

@@ -38,0 +45,0 @@ if (syncResub) {

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { identity } from '../util/identity';

@@ -19,3 +19,3 @@ import { timer } from '../observable/timer';

? identity
: (source) => new Observable((subscriber) => {
: (source) => new Observable((destination) => {
let soFar = 0;

@@ -25,36 +25,44 @@ let innerSub;

let syncUnsub = false;
innerSub = source.subscribe(createOperatorSubscriber(subscriber, (value) => {
if (resetOnSuccess) {
soFar = 0;
}
subscriber.next(value);
}, undefined, (err) => {
if (soFar++ < count) {
const resub = () => {
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
subscribeForRetry();
innerSub = source.subscribe(operate({
destination,
next: (value) => {
if (resetOnSuccess) {
soFar = 0;
}
destination.next(value);
},
error: (err) => {
if (soFar++ < count) {
const resub = () => {
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
subscribeForRetry();
}
else {
syncUnsub = true;
}
};
if (delay != null) {
const notifier = typeof delay === 'number' ? timer(delay) : from(delay(err, soFar));
const notifierSubscriber = operate({
destination,
next: () => {
notifierSubscriber.unsubscribe();
resub();
},
complete: () => {
destination.complete();
},
});
notifier.subscribe(notifierSubscriber);
}
else {
syncUnsub = true;
resub();
}
};
if (delay != null) {
const notifier = typeof delay === 'number' ? timer(delay) : from(delay(err, soFar));
const notifierSubscriber = createOperatorSubscriber(subscriber, () => {
notifierSubscriber.unsubscribe();
resub();
}, () => {
subscriber.complete();
});
notifier.subscribe(notifierSubscriber);
}
else {
resub();
destination.error(err);
}
}
else {
subscriber.error(err);
}
},
}));

@@ -61,0 +69,0 @@ if (syncUnsub) {

import { Observable } from '../Observable';
import { from } from '../observable/from';
import { Subject } from '../Subject';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function retryWhen(notifier) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let innerSub;

@@ -11,10 +11,16 @@ let syncResub = false;

const subscribeForRetryWhen = () => {
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, (err) => {
if (!errors$) {
errors$ = new Subject();
from(notifier(errors$)).subscribe(createOperatorSubscriber(subscriber, () => innerSub ? subscribeForRetryWhen() : (syncResub = true)));
}
if (errors$) {
errors$.next(err);
}
innerSub = source.subscribe(operate({
destination,
error: (err) => {
if (!errors$) {
errors$ = new Subject();
from(notifier(errors$)).subscribe(operate({
destination,
next: () => innerSub ? subscribeForRetryWhen() : (syncResub = true),
}));
}
if (errors$) {
errors$.next(err);
}
},
}));

@@ -21,0 +27,0 @@ if (syncResub) {

import { from } from '../observable/from';
import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function sample(notifier) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let hasValue = false;
let lastValue = null;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
lastValue = value;
source.subscribe(operate({
destination,
next: (value) => {
hasValue = true;
lastValue = value;
},
}));
from(notifier).subscribe(createOperatorSubscriber(subscriber, () => {
if (hasValue) {
hasValue = false;
const value = lastValue;
lastValue = null;
subscriber.next(value);
}
}, noop));
from(notifier).subscribe(operate({
destination,
next: () => {
if (hasValue) {
hasValue = false;
const value = lastValue;
lastValue = null;
destination.next(value);
}
},
complete: noop,
}));
});
}
//# sourceMappingURL=sample.js.map

@@ -1,21 +0,25 @@

import { createOperatorSubscriber } from './OperatorSubscriber';
export function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete, source, subscriber) {
import { operate } from '../Subscriber';
export function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete, source, destination) {
let hasState = hasSeed;
let state = seed;
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const i = index++;
state = hasState
?
accumulator(state, value, i)
:
((hasState = true), value);
emitOnNext && subscriber.next(state);
}, emitBeforeComplete
? () => {
hasState && subscriber.next(state);
subscriber.complete();
}
: undefined));
source.subscribe(operate({
destination,
next: (value) => {
const i = index++;
state = hasState
?
accumulator(state, value, i)
:
((hasState = true), value);
emitOnNext && destination.next(state);
},
complete: emitBeforeComplete
? () => {
hasState && destination.next(state);
destination.complete();
}
: undefined,
}));
}
//# sourceMappingURL=scanInternals.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';
export function sequenceEqual(compareTo, comparator = (a, b) => a === b) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
const aState = createState();
const bState = createState();
const emit = (isEqual) => {
subscriber.next(isEqual);
subscriber.complete();
destination.next(isEqual);
destination.complete();
};
const createSubscriber = (selfState, otherState) => {
const sequenceEqualSubscriber = createOperatorSubscriber(subscriber, (a) => {
const { buffer, complete } = otherState;
if (buffer.length === 0) {
complete ? emit(false) : selfState.buffer.push(a);
}
else {
!comparator(a, buffer.shift()) && emit(false);
}
}, () => {
selfState.complete = true;
const { complete, buffer } = otherState;
complete && emit(buffer.length === 0);
sequenceEqualSubscriber === null || sequenceEqualSubscriber === void 0 ? void 0 : sequenceEqualSubscriber.unsubscribe();
const sequenceEqualSubscriber = operate({
destination,
next: (a) => {
const { buffer, complete } = otherState;
if (buffer.length === 0) {
complete ? emit(false) : selfState.buffer.push(a);
}
else {
!comparator(a, buffer.shift()) && emit(false);
}
},
complete: () => {
selfState.complete = true;
const { complete, buffer } = otherState;
complete && emit(buffer.length === 0);
sequenceEqualSubscriber?.unsubscribe();
},
});

@@ -27,0 +31,0 @@ return sequenceEqualSubscriber;

@@ -15,3 +15,3 @@ import { Observable } from '../Observable';

const cancelReset = () => {
resetConnection === null || resetConnection === void 0 ? void 0 : resetConnection.unsubscribe();
resetConnection?.unsubscribe();
resetConnection = undefined;

@@ -27,3 +27,3 @@ };

reset();
conn === null || conn === void 0 ? void 0 : conn.unsubscribe();
conn?.unsubscribe();
};

@@ -35,3 +35,3 @@ return new Observable((subscriber) => {

}
const dest = (subject = subject !== null && subject !== void 0 ? subject : connector());
const dest = (subject = subject ?? connector());
subscriber.add(() => {

@@ -38,0 +38,0 @@ refCount--;

@@ -10,3 +10,3 @@ import { ReplaySubject } from '../ReplaySubject';

else {
bufferSize = (configOrBufferSize !== null && configOrBufferSize !== void 0 ? configOrBufferSize : Infinity);
bufferSize = (configOrBufferSize ?? Infinity);
}

@@ -13,0 +13,0 @@ return share({

@@ -5,5 +5,5 @@ import { Observable } from '../Observable';

import { NotFoundError } from '../util/NotFoundError';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function single(predicate) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let hasValue = false;

@@ -13,17 +13,21 @@ let singleValue;

let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
seenValue = true;
if (!predicate || predicate(value, index++, source)) {
hasValue && subscriber.error(new SequenceError('Too many matching values'));
hasValue = true;
singleValue = value;
}
}, () => {
if (hasValue) {
subscriber.next(singleValue);
subscriber.complete();
}
else {
subscriber.error(seenValue ? new NotFoundError('No matching values') : new EmptyError());
}
source.subscribe(operate({
destination,
next: (value) => {
seenValue = true;
if (!predicate || predicate(value, index++, source)) {
hasValue && destination.error(new SequenceError('Too many matching values'));
hasValue = true;
singleValue = value;
}
},
complete: () => {
if (hasValue) {
destination.next(singleValue);
destination.complete();
}
else {
destination.error(seenValue ? new NotFoundError('No matching values') : new EmptyError());
}
},
}));

@@ -30,0 +34,0 @@ });

import { identity } from '../util/identity';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function skipLast(skipCount) {

@@ -8,16 +8,19 @@ return skipCount <= 0

identity
: (source) => new Observable((subscriber) => {
: (source) => new Observable((destination) => {
let ring = new Array(skipCount);
let seen = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const valueIndex = seen++;
if (valueIndex < skipCount) {
ring[valueIndex] = value;
}
else {
const index = valueIndex % skipCount;
const oldValue = ring[index];
ring[index] = value;
subscriber.next(oldValue);
}
source.subscribe(operate({
destination,
next: (value) => {
const valueIndex = seen++;
if (valueIndex < skipCount) {
ring[valueIndex] = value;
}
else {
const index = valueIndex % skipCount;
const oldValue = ring[index];
ring[index] = value;
destination.next(oldValue);
}
},
}));

@@ -24,0 +27,0 @@ return () => {

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';
import { noop } from '../util/noop';
export function skipUntil(notifier) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let taking = false;
const skipSubscriber = createOperatorSubscriber(subscriber, () => {
skipSubscriber === null || skipSubscriber === void 0 ? void 0 : skipSubscriber.unsubscribe();
taking = true;
}, noop);
const skipSubscriber = operate({
destination,
next: () => {
skipSubscriber?.unsubscribe();
taking = true;
},
complete: noop,
});
from(notifier).subscribe(skipSubscriber);
source.subscribe(createOperatorSubscriber(subscriber, (value) => taking && subscriber.next(value)));
source.subscribe(operate({ destination, next: (value) => taking && destination.next(value) }));
});
}
//# sourceMappingURL=skipUntil.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function skipWhile(predicate) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let taking = false;
let index = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => (taking || (taking = !predicate(value, index++))) && subscriber.next(value)));
source.subscribe(operate({ destination, next: (value) => (taking || (taking = !predicate(value, index++))) && destination.next(value) }));
});
}
//# sourceMappingURL=skipWhile.js.map

@@ -1,10 +0,9 @@

import { concat } from '../observable/concat';
import { popScheduler } from '../util/args';
import { Observable } from '../Observable';
import { subscribeToArray } from '../observable/from';
import { operate } from '../Subscriber';
export function startWith(...values) {
const scheduler = popScheduler(values);
return (source) => new Observable((subscriber) => {
(scheduler ? concat(values, source, scheduler) : concat(values, source)).subscribe(subscriber);
return (source) => new Observable((destination) => {
subscribeToArray(values, operate({ destination, complete: () => source.subscribe(destination) }));
});
}
//# sourceMappingURL=startWith.js.map

@@ -0,20 +1,27 @@

import { operate } from '../Subscriber';
import { from } from '../observable/from';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function switchMap(project) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let innerSubscriber = null;
let index = 0;
let isComplete = false;
const checkComplete = () => isComplete && !innerSubscriber && subscriber.complete();
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
const outerIndex = index++;
from(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, undefined, () => {
innerSubscriber = null;
const checkComplete = () => isComplete && !innerSubscriber && destination.complete();
source.subscribe(operate({
destination,
next: (value) => {
innerSubscriber?.unsubscribe();
const outerIndex = index++;
from(project(value, outerIndex)).subscribe((innerSubscriber = operate({
destination,
complete: () => {
innerSubscriber = null;
checkComplete();
},
})));
},
complete: () => {
isComplete = true;
checkComplete();
})));
}, () => {
isComplete = true;
checkComplete();
},
}));

@@ -21,0 +28,0 @@ });

import { switchMap } from './switchMap';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function switchScan(accumulator, seed) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let state = seed;
switchMap((value, index) => accumulator(state, value, index))(source).subscribe(createOperatorSubscriber(subscriber, (innerValue) => {
state = innerValue;
subscriber.next(innerValue);
switchMap((value, index) => accumulator(state, value, index))(source).subscribe(operate({
destination,
next: (innerValue) => {
state = innerValue;
destination.next(innerValue);
},
}));

@@ -11,0 +14,0 @@ return () => {

import { EMPTY } from '../observable/empty';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function take(count) {

@@ -8,13 +8,16 @@ return count <= 0

() => EMPTY
: (source) => new Observable((subscriber) => {
: (source) => new Observable((destination) => {
let seen = 0;
const operatorSubscriber = createOperatorSubscriber(subscriber, (value) => {
if (++seen < count) {
subscriber.next(value);
}
else {
operatorSubscriber.unsubscribe();
subscriber.next(value);
subscriber.complete();
}
const operatorSubscriber = operate({
destination,
next: (value) => {
if (++seen < count) {
destination.next(value);
}
else {
operatorSubscriber.unsubscribe();
destination.next(value);
destination.complete();
}
},
});

@@ -21,0 +24,0 @@ source.subscribe(operatorSubscriber);

import { EMPTY } from '../observable/empty';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function takeLast(count) {
return count <= 0
? () => EMPTY
: (source) => new Observable((subscriber) => {
: (source) => new Observable((destination) => {
let ring = new Array(count);
let counter = 0;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
ring[counter++ % count] = value;
}, () => {
const start = count <= counter ? counter : 0;
const total = Math.min(count, counter);
for (let n = 0; n < total; n++) {
subscriber.next(ring[(start + n) % count]);
}
subscriber.complete();
}, undefined, () => {
ring = null;
source.subscribe(operate({
destination,
next: (value) => {
ring[counter++ % count] = value;
},
complete: () => {
const start = count <= counter ? counter : 0;
const total = Math.min(count, counter);
for (let n = 0; n < total; n++) {
destination.next(ring[(start + n) % count]);
}
destination.complete();
},
finalize: () => {
ring = null;
},
}));

@@ -22,0 +27,0 @@ });

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';
import { noop } from '../util/noop';
export function takeUntil(notifier) {
return (source) => new Observable((subscriber) => {
from(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
!subscriber.closed && source.subscribe(subscriber);
return (source) => new Observable((destination) => {
from(notifier).subscribe(operate({ destination, next: () => destination.complete(), complete: noop }));
!destination.closed && source.subscribe(destination);
});
}
//# sourceMappingURL=takeUntil.js.map
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function takeWhile(predicate, inclusive = false) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let index = 0;
const operatorSubscriber = createOperatorSubscriber(subscriber, (value) => {
if (predicate(value, index++)) {
subscriber.next(value);
}
else {
operatorSubscriber.unsubscribe();
if (inclusive) {
subscriber.next(value);
const operatorSubscriber = operate({
destination,
next: (value) => {
if (predicate(value, index++)) {
destination.next(value);
}
subscriber.complete();
}
else {
operatorSubscriber.unsubscribe();
if (inclusive) {
destination.next(value);
}
destination.complete();
}
},
});

@@ -18,0 +21,0 @@ source.subscribe(operatorSubscriber);

import { isFunction } from '../util/isFunction';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { identity } from '../util/identity';

@@ -8,26 +8,27 @@ export function tap(observerOrNext) {

return tapObserver
? (source) => new Observable((subscriber) => {
var _a;
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
? (source) => new Observable((destination) => {
tapObserver.subscribe?.();
let isUnsub = true;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
var _a;
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
subscriber.next(value);
}, () => {
var _a;
isUnsub = false;
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
subscriber.complete();
}, (err) => {
var _a;
isUnsub = false;
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
subscriber.error(err);
}, () => {
var _a, _b;
if (isUnsub) {
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
}
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
source.subscribe(operate({
destination,
next: (value) => {
tapObserver.next?.(value);
destination.next(value);
},
error: (err) => {
isUnsub = false;
tapObserver.error?.(err);
destination.error(err);
},
complete: () => {
isUnsub = false;
tapObserver.complete?.();
destination.complete();
},
finalize: () => {
if (isUnsub) {
tapObserver.unsubscribe?.();
}
tapObserver.finalize?.();
},
}));

@@ -34,0 +35,0 @@ })

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';
export function throttle(durationSelector, config) {
return (source) => new Observable((subscriber) => {
const { leading = true, trailing = false } = config !== null && config !== void 0 ? config : {};
return (source) => new Observable((destination) => {
const { leading = true, trailing = false } = config ?? {};
let hasValue = false;

@@ -12,7 +12,7 @@ let sendValue = null;

const endThrottling = () => {
throttled === null || throttled === void 0 ? void 0 : throttled.unsubscribe();
throttled?.unsubscribe();
throttled = null;
if (trailing) {
send();
isComplete && subscriber.complete();
isComplete && destination.complete();
}

@@ -22,5 +22,5 @@ };

throttled = null;
isComplete && subscriber.complete();
isComplete && destination.complete();
};
const startThrottle = (value) => (throttled = from(durationSelector(value)).subscribe(createOperatorSubscriber(subscriber, endThrottling, cleanupThrottling)));
const startThrottle = (value) => (throttled = from(durationSelector(value)).subscribe(operate({ destination, next: endThrottling, complete: cleanupThrottling })));
const send = () => {

@@ -31,13 +31,17 @@ if (hasValue) {

sendValue = null;
subscriber.next(value);
destination.next(value);
!isComplete && startThrottle(value);
}
};
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
sendValue = value;
!(throttled && !throttled.closed) && (leading ? send() : startThrottle(value));
}, () => {
isComplete = true;
!(trailing && hasValue && throttled && !throttled.closed) && subscriber.complete();
source.subscribe(operate({
destination,
next: (value) => {
hasValue = true;
sendValue = value;
!(throttled && !throttled.closed) && (leading ? send() : startThrottle(value));
},
complete: () => {
isComplete = true;
!(trailing && hasValue && throttled && !throttled.closed) && destination.complete();
},
}));

@@ -44,0 +48,0 @@ });

import { EmptyError } from '../util/EmptyError';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function throwIfEmpty(errorFactory = defaultErrorFactory) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let hasValue = false;
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
subscriber.next(value);
}, () => (hasValue ? subscriber.complete() : subscriber.error(errorFactory()))));
source.subscribe(operate({
destination,
next: (value) => {
hasValue = true;
destination.next(value);
},
complete: () => (hasValue ? destination.complete() : destination.error(errorFactory())),
}));
});

@@ -12,0 +16,0 @@ }

import { asyncScheduler } from '../scheduler/async';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function timeInterval(scheduler = asyncScheduler) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let last = scheduler.now();
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const now = scheduler.now();
const interval = now - last;
last = now;
subscriber.next(new TimeInterval(value, interval));
source.subscribe(operate({
destination,
next: (value) => {
const now = scheduler.now();
const interval = now - last;
last = now;
destination.next(new TimeInterval(value, interval));
},
}));

@@ -16,2 +19,4 @@ });

export class TimeInterval {
value;
interval;
constructor(value, interval) {

@@ -18,0 +23,0 @@ this.value = value;

@@ -5,17 +5,18 @@ import { asyncScheduler } from '../scheduler/async';

import { from } from '../observable/from';
import { createErrorClass } from '../util/createErrorClass';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { executeSchedule } from '../util/executeSchedule';
export const TimeoutError = createErrorClass((_super) => function TimeoutErrorImpl(info = null) {
_super(this);
this.message = 'Timeout has occurred';
this.name = 'TimeoutError';
this.info = info;
});
export class TimeoutError extends Error {
info;
constructor(info = null) {
super('Timeout has occurred');
this.info = info;
this.name = 'TimeoutError';
}
}
export function timeout(config, schedulerArg) {
const { first, each, with: _with = timeoutErrorFactory, scheduler = schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : asyncScheduler, meta = null, } = (isValidDate(config) ? { first: config } : typeof config === 'number' ? { each: config } : config);
const { first, each, with: _with = timeoutErrorFactory, scheduler = schedulerArg ?? asyncScheduler, meta = null, } = (isValidDate(config) ? { first: config } : typeof config === 'number' ? { each: config } : config);
if (first == null && each == null) {
throw new TypeError('No timeout provided.');
}
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let originalSourceSubscription;

@@ -26,3 +27,3 @@ let timerSubscription;

const startTimer = (delay) => {
timerSubscription = executeSchedule(subscriber, scheduler, () => {
timerSubscription = executeSchedule(destination, scheduler, () => {
try {

@@ -34,19 +35,23 @@ originalSourceSubscription.unsubscribe();

seen,
})).subscribe(subscriber);
})).subscribe(destination);
}
catch (err) {
subscriber.error(err);
destination.error(err);
}
}, delay);
};
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, (value) => {
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
seen++;
subscriber.next((lastValue = value));
each > 0 && startTimer(each);
}, undefined, undefined, () => {
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) {
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe();
}
lastValue = null;
originalSourceSubscription = source.subscribe(operate({
destination,
next: (value) => {
timerSubscription?.unsubscribe();
seen++;
destination.next((lastValue = value));
each > 0 && startTimer(each);
},
finalize: () => {
if (!timerSubscription?.closed) {
timerSubscription?.unsubscribe();
}
lastValue = null;
},
}));

@@ -53,0 +58,0 @@ !seen && startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each);

@@ -8,3 +8,3 @@ import { asyncScheduler } from '../scheduler/async';

let _with;
scheduler = scheduler !== null && scheduler !== void 0 ? scheduler : asyncScheduler;
scheduler = scheduler ?? asyncScheduler;
if (isValidDate(due)) {

@@ -11,0 +11,0 @@ first = due;

import { Observable } from '../Observable';
import { Subject } from '../Subject';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';
import { from } from '../observable/from';
export function window(windowBoundaries) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let windowSubject = new Subject();
subscriber.next(windowSubject.asObservable());
destination.next(windowSubject.asObservable());
const errorHandler = (err) => {
windowSubject.error(err);
subscriber.error(err);
destination.error(err);
};
source.subscribe(createOperatorSubscriber(subscriber, (value) => windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value), () => {
windowSubject.complete();
subscriber.complete();
}, errorHandler));
from(windowBoundaries).subscribe(createOperatorSubscriber(subscriber, () => {
windowSubject.complete();
subscriber.next((windowSubject = new Subject()));
}, noop, errorHandler));
source.subscribe(operate({
destination,
next: (value) => windowSubject?.next(value),
complete: () => {
windowSubject.complete();
destination.complete();
},
error: errorHandler,
}));
from(windowBoundaries).subscribe(operate({
destination,
next: () => {
windowSubject.complete();
destination.next((windowSubject = new Subject()));
},
complete: noop,
error: errorHandler,
}));
return () => {
windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe();
windowSubject?.unsubscribe();
windowSubject = null;

@@ -25,0 +35,0 @@ };

import { Observable } from '../Observable';
import { Subject } from '../Subject';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
export function windowCount(windowSize, startWindowEvery = 0) {
const startEvery = startWindowEvery > 0 ? startWindowEvery : windowSize;
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let windows = [new Subject()];
let starts = [];
let count = 0;
subscriber.next(windows[0].asObservable());
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
for (const window of windows) {
window.next(value);
}
const c = count - windowSize + 1;
if (c >= 0 && c % startEvery === 0) {
windows.shift().complete();
}
if (++count % startEvery === 0) {
const window = new Subject();
windows.push(window);
subscriber.next(window.asObservable());
}
}, () => {
while (windows.length > 0) {
windows.shift().complete();
}
subscriber.complete();
}, (err) => {
while (windows.length > 0) {
windows.shift().error(err);
}
subscriber.error(err);
}, () => {
starts = null;
windows = null;
destination.next(windows[0].asObservable());
source.subscribe(operate({
destination,
next: (value) => {
for (const window of windows) {
window.next(value);
}
const c = count - windowSize + 1;
if (c >= 0 && c % startEvery === 0) {
windows.shift().complete();
}
if (++count % startEvery === 0) {
const window = new Subject();
windows.push(window);
destination.next(window.asObservable());
}
},
error: (err) => {
while (windows.length > 0) {
windows.shift().error(err);
}
destination.error(err);
},
complete: () => {
while (windows.length > 0) {
windows.shift().complete();
}
destination.complete();
},
finalize: () => {
starts = null;
windows = null;
},
}));

@@ -38,0 +44,0 @@ });

@@ -5,3 +5,3 @@ import { Subject } from '../Subject';

import { Subscription } from '../Subscription';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { arrRemove } from '../util/arrRemove';

@@ -11,7 +11,6 @@ import { popScheduler } from '../util/args';

export function windowTime(windowTimeSpan, ...otherArgs) {
var _a, _b;
const scheduler = (_a = popScheduler(otherArgs)) !== null && _a !== void 0 ? _a : asyncScheduler;
const windowCreationInterval = (_b = otherArgs[0]) !== null && _b !== void 0 ? _b : null;
const scheduler = popScheduler(otherArgs) ?? asyncScheduler;
const windowCreationInterval = otherArgs[0] ?? null;
const maxWindowSize = otherArgs[1] || Infinity;
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let windowRecords = [];

@@ -29,3 +28,3 @@ let restartOnClose = false;

const subs = new Subscription();
subscriber.add(subs);
destination.add(subs);
const window = new Subject();

@@ -38,3 +37,3 @@ const record = {

windowRecords.push(record);
subscriber.next(window.asObservable());
destination.next(window.asObservable());
executeSchedule(subs, scheduler, () => closeWindow(record), windowTimeSpan);

@@ -44,3 +43,3 @@ }

if (windowCreationInterval !== null && windowCreationInterval >= 0) {
executeSchedule(subscriber, scheduler, startWindow, windowCreationInterval, true);
executeSchedule(destination, scheduler, startWindow, windowCreationInterval, true);
}

@@ -54,11 +53,16 @@ else {

loop(({ window }) => cb(window));
cb(subscriber);
subscriber.unsubscribe();
cb(destination);
destination.unsubscribe();
};
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
loop((record) => {
record.window.next(value);
maxWindowSize <= ++record.seen && closeWindow(record);
});
}, () => terminate((consumer) => consumer.complete()), (err) => terminate((consumer) => consumer.error(err))));
source.subscribe(operate({
destination,
next: (value) => {
loop((record) => {
record.window.next(value);
maxWindowSize <= ++record.seen && closeWindow(record);
});
},
error: (err) => terminate((consumer) => consumer.error(err)),
complete: () => terminate((consumer) => consumer.complete()),
}));
return () => {

@@ -65,0 +69,0 @@ windowRecords = null;

@@ -5,7 +5,7 @@ import { Observable } from '../Observable';

import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';
import { arrRemove } from '../util/arrRemove';
export function windowToggle(openings, closingSelector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
const windows = [];

@@ -16,41 +16,56 @@ const handleError = (err) => {

}
subscriber.error(err);
destination.error(err);
};
from(openings).subscribe(createOperatorSubscriber(subscriber, (openValue) => {
const window = new Subject();
windows.push(window);
const closingSubscription = new Subscription();
const closeWindow = () => {
arrRemove(windows, window);
window.complete();
closingSubscription.unsubscribe();
};
let closingNotifier;
try {
closingNotifier = from(closingSelector(openValue));
}
catch (err) {
handleError(err);
return;
}
subscriber.next(window);
closingSubscription.add(closingNotifier.subscribe(createOperatorSubscriber(subscriber, closeWindow, noop, handleError)));
}, noop));
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const windowsCopy = windows.slice();
for (const window of windowsCopy) {
window.next(value);
}
}, () => {
while (0 < windows.length) {
windows.shift().complete();
}
subscriber.complete();
}, handleError, () => {
while (0 < windows.length) {
windows.shift().unsubscribe();
}
from(openings).subscribe(operate({
destination,
next: (openValue) => {
const window = new Subject();
windows.push(window);
const closingSubscription = new Subscription();
const closeWindow = () => {
arrRemove(windows, window);
window.complete();
closingSubscription.unsubscribe();
};
let closingNotifier;
try {
closingNotifier = from(closingSelector(openValue));
}
catch (err) {
handleError(err);
return;
}
destination.next(window);
closingSubscription.add(closingNotifier.subscribe(operate({
destination,
next: closeWindow,
error: handleError,
complete: noop,
})));
},
complete: noop,
}));
source.subscribe(operate({
destination,
next: (value) => {
const windowsCopy = windows.slice();
for (const window of windowsCopy) {
window.next(value);
}
},
error: handleError,
complete: () => {
while (0 < windows.length) {
windows.shift().complete();
}
destination.complete();
},
finalize: () => {
while (0 < windows.length) {
windows.shift().unsubscribe();
}
},
}));
});
}
//# sourceMappingURL=windowToggle.js.map

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

import { operate } from '../Subscriber';
import { Observable } from '../Observable';
import { Subject } from '../Subject';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { from } from '../observable/from';
import { noop } from '../util/noop';
export function windowWhen(closingSelector) {
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
let window;

@@ -12,9 +12,9 @@ let closingSubscriber;

window.error(err);
subscriber.error(err);
destination.error(err);
};
const openWindow = () => {
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe();
window === null || window === void 0 ? void 0 : window.complete();
closingSubscriber?.unsubscribe();
window?.complete();
window = new Subject();
subscriber.next(window.asObservable());
destination.next(window.asObservable());
let closingNotifier;

@@ -28,11 +28,22 @@ try {

}
closingNotifier.subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openWindow, noop, handleError)));
closingNotifier.subscribe((closingSubscriber = operate({
destination,
next: openWindow,
error: handleError,
complete: noop,
})));
};
openWindow();
source.subscribe(createOperatorSubscriber(subscriber, (value) => window.next(value), () => {
window.complete();
subscriber.complete();
}, handleError, () => {
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe();
window = null;
source.subscribe(operate({
destination,
next: (value) => window.next(value),
error: handleError,
complete: () => {
window.complete();
destination.complete();
},
finalize: () => {
closingSubscriber?.unsubscribe();
window = null;
},
}));

@@ -39,0 +50,0 @@ });

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -9,3 +9,3 @@ import { identity } from '../util/identity';

const project = popResultSelector(inputs);
return (source) => new Observable((subscriber) => {
return (source) => new Observable((destination) => {
const len = inputs.length;

@@ -16,15 +16,22 @@ const otherValues = new Array(len);

for (let i = 0; i < len; i++) {
from(inputs[i]).subscribe(createOperatorSubscriber(subscriber, (value) => {
otherValues[i] = value;
if (!ready && !hasValue[i]) {
hasValue[i] = true;
(ready = hasValue.every(identity)) && (hasValue = null);
from(inputs[i]).subscribe(operate({
destination,
next: (value) => {
otherValues[i] = value;
if (!ready && !hasValue[i]) {
hasValue[i] = true;
(ready = hasValue.every(identity)) && (hasValue = null);
}
},
complete: noop,
}));
}
source.subscribe(operate({
destination,
next: (value) => {
if (ready) {
const values = [value, ...otherValues];
destination.next(project ? project(...values) : values);
}
}, noop));
}
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
if (ready) {
const values = [value, ...otherValues];
subscriber.next(project ? project(...values) : values);
}
},
}));

@@ -31,0 +38,0 @@ });

import { Subject } from './Subject';
import { dateTimestampProvider } from './scheduler/dateTimestampProvider';
export class ReplaySubject extends Subject {
_bufferSize;
_windowTime;
_timestampProvider;
_buffer = [];
_infiniteTimeWindow = true;
constructor(_bufferSize = Infinity, _windowTime = Infinity, _timestampProvider = dateTimestampProvider) {

@@ -9,4 +14,2 @@ super();

this._timestampProvider = _timestampProvider;
this._buffer = [];
this._infiniteTimeWindow = true;
this._infiniteTimeWindow = _windowTime === Infinity;

@@ -13,0 +16,0 @@ this._bufferSize = Math.max(1, _bufferSize);

@@ -28,5 +28,5 @@ import { Observable } from '../Observable';

});
return () => isFunction(iterator === null || iterator === void 0 ? void 0 : iterator.return) && iterator.return();
return () => isFunction(iterator?.return) && iterator.return();
});
}
//# sourceMappingURL=scheduleIterable.js.map
import { dateTimestampProvider } from './scheduler/dateTimestampProvider';
export class Scheduler {
schedulerActionCtor;
static now = dateTimestampProvider.now;
constructor(schedulerActionCtor, now = Scheduler.now) {

@@ -7,2 +9,3 @@ this.schedulerActionCtor = schedulerActionCtor;

}
now;
schedule(work, delay = 0, state) {

@@ -12,3 +15,2 @@ return new this.schedulerActionCtor(this, work).schedule(state, delay);

}
Scheduler.now = dateTimestampProvider.now;
//# sourceMappingURL=Scheduler.js.map
import { AsyncAction } from './AsyncAction';
import { animationFrameProvider } from './animationFrameProvider';
export class AnimationFrameAction extends AsyncAction {
scheduler;
work;
constructor(scheduler, work) {

@@ -17,3 +19,2 @@ super(scheduler, work);

recycleAsyncId(scheduler, id, delay = 0) {
var _a;
if (delay != null ? delay > 0 : this.delay > 0) {

@@ -23,3 +24,3 @@ return super.recycleAsyncId(scheduler, id, delay);

const { actions } = scheduler;
if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) {
if (id != null && actions[actions.length - 1]?.id !== id) {
animationFrameProvider.cancelAnimationFrame(id);

@@ -26,0 +27,0 @@ scheduler._scheduled = undefined;

@@ -15,11 +15,11 @@ import { Subscription } from '../Subscription';

});
return new Subscription(() => cancel === null || cancel === void 0 ? void 0 : cancel(handle));
return new Subscription(() => cancel?.(handle));
},
requestAnimationFrame(...args) {
const { delegate } = animationFrameProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame)(...args);
return (delegate?.requestAnimationFrame || requestAnimationFrame)(...args);
},
cancelAnimationFrame(...args) {
const { delegate } = animationFrameProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame)(...args);
return (delegate?.cancelAnimationFrame || cancelAnimationFrame)(...args);
},

@@ -26,0 +26,0 @@ delegate: undefined,

import { AsyncAction } from './AsyncAction';
import { immediateProvider } from './immediateProvider';
export class AsapAction extends AsyncAction {
scheduler;
work;
constructor(scheduler, work) {

@@ -17,3 +19,2 @@ super(scheduler, work);

recycleAsyncId(scheduler, id, delay = 0) {
var _a;
if (delay != null ? delay > 0 : this.delay > 0) {

@@ -23,3 +24,3 @@ return super.recycleAsyncId(scheduler, id, delay);

const { actions } = scheduler;
if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) {
if (id != null && actions[actions.length - 1]?.id !== id) {
immediateProvider.clearImmediate(id);

@@ -26,0 +27,0 @@ if (scheduler._scheduled === id) {

@@ -5,2 +5,8 @@ import { Action } from './Action';

export class AsyncAction extends Action {
scheduler;
work;
id;
state;
delay;
pending = false;
constructor(scheduler, work) {

@@ -10,6 +16,4 @@ super(scheduler, work);

this.work = work;
this.pending = false;
}
schedule(state, delay = 0) {
var _a;
if (this.closed) {

@@ -26,3 +30,3 @@ return this;

this.delay = delay;
this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
this.id = this.id ?? this.requestAsyncId(scheduler, this.id, delay);
return this;

@@ -29,0 +33,0 @@ }

import { Scheduler } from '../Scheduler';
export class AsyncScheduler extends Scheduler {
actions = [];
_active = false;
_scheduled;
constructor(SchedulerAction, now = Scheduler.now) {
super(SchedulerAction, now);
this.actions = [];
this._active = false;
}

@@ -8,0 +9,0 @@ flush(action) {

@@ -6,7 +6,7 @@ import { Immediate } from '../util/Immediate';

const { delegate } = immediateProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setImmediate) || setImmediate)(...args);
return (delegate?.setImmediate || setImmediate)(...args);
},
clearImmediate(handle) {
const { delegate } = immediateProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearImmediate) || clearImmediate)(handle);
return (delegate?.clearImmediate || clearImmediate)(handle);
},

@@ -13,0 +13,0 @@ delegate: undefined,

export const intervalProvider = {
setInterval(handler, timeout, ...args) {
const { delegate } = intervalProvider;
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
if (delegate?.setInterval) {
return delegate.setInterval(handler, timeout, ...args);

@@ -11,3 +11,3 @@ }

const { delegate } = intervalProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
return (delegate?.clearInterval || clearInterval)(handle);
},

@@ -14,0 +14,0 @@ delegate: undefined,

import { AsyncAction } from './AsyncAction';
export class QueueAction extends AsyncAction {
scheduler;
work;
constructor(scheduler, work) {

@@ -4,0 +6,0 @@ super(scheduler, work);

export const timeoutProvider = {
setTimeout(handler, timeout, ...args) {
const { delegate } = timeoutProvider;
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
if (delegate?.setTimeout) {
return delegate.setTimeout(handler, timeout, ...args);

@@ -11,3 +11,3 @@ }

const { delegate } = timeoutProvider;
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
return (delegate?.clearTimeout || clearTimeout)(handle);
},

@@ -14,0 +14,0 @@ delegate: undefined,

@@ -5,7 +5,9 @@ import { AsyncAction } from './AsyncAction';

export class VirtualTimeScheduler extends AsyncScheduler {
maxFrames;
static frameTimeFactor = 10;
frame = 0;
index = -1;
constructor(schedulerActionCtor = VirtualAction, maxFrames = Infinity) {
super(schedulerActionCtor, () => this.frame);
this.maxFrames = maxFrames;
this.frame = 0;
this.index = -1;
}

@@ -31,4 +33,7 @@ flush() {

}
VirtualTimeScheduler.frameTimeFactor = 10;
export class VirtualAction extends AsyncAction {
scheduler;
work;
index;
active = true;
constructor(scheduler, work, index = (scheduler.index += 1)) {

@@ -39,3 +44,2 @@ super(scheduler, work);

this.index = index;
this.active = true;
this.index = scheduler.index = index;

@@ -42,0 +46,0 @@ }

import { Observable } from './Observable';
import { Subscription } from './Subscription';
export class Subject extends Observable {
_closed = false;
get closed() {
return this._closed;
}
_observerCounter = 0;
currentObservers = new Map();
observerSnapshot;
get observers() {
var _a;
return ((_a = this.observerSnapshot) !== null && _a !== void 0 ? _a : (this.observerSnapshot = Array.from(this.currentObservers.values())));
return (this.observerSnapshot ??= Array.from(this.currentObservers.values()));
}
hasError = false;
thrownError = null;
static create = (destination, source) => {
return new AnonymousSubject(destination, source);
};
constructor() {
super();
this._closed = false;
this._observerCounter = 0;
this.currentObservers = new Map();
this.hasError = false;
this.thrownError = null;
}

@@ -93,6 +96,5 @@ _clearObservers() {

}
Subject.create = (destination, source) => {
return new AnonymousSubject(destination, source);
};
export class AnonymousSubject extends Subject {
destination;
_source;
constructor(destination, _source) {

@@ -104,18 +106,14 @@ super();

next(value) {
var _a, _b;
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
this.destination?.next?.(value);
}
error(err) {
var _a, _b;
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
this.destination?.error?.(err);
}
complete() {
var _a, _b;
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
this.destination?.complete?.();
}
_subscribe(subscriber) {
var _a, _b;
return (_b = (_a = this._source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : Subscription.EMPTY;
return this._source?.subscribe(subscriber) ?? Subscription.EMPTY;
}
}
//# sourceMappingURL=Subject.js.map

@@ -8,6 +8,18 @@ import { isFunction } from './util/isFunction';

export class Subscriber extends Subscription {
constructor(destination) {
isStopped = false;
destination;
_nextOverride = null;
_errorOverride = null;
_completeOverride = null;
_onFinalize = null;
constructor(destination, overrides) {
super();
this.isStopped = false;
this.destination = destination instanceof Subscriber ? destination : createSafeObserver(destination);
this._nextOverride = overrides?.next ?? null;
this._errorOverride = overrides?.error ?? null;
this._completeOverride = overrides?.complete ?? null;
this._onFinalize = overrides?.finalize ?? null;
this._next = this._nextOverride ? overrideNext : this._next;
this._error = this._errorOverride ? overrideError : this._error;
this._complete = this._completeOverride ? overrideComplete : this._complete;
if (hasAddAndUnsubscribe(destination)) {

@@ -47,3 +59,3 @@ destination.add(this);

super.unsubscribe();
this.destination = null;
this._onFinalize?.();
}

@@ -71,3 +83,34 @@ }

}
function overrideNext(value) {
try {
this._nextOverride(value);
}
catch (error) {
this.destination.error(error);
}
}
function overrideError(err) {
try {
this._errorOverride(err);
}
catch (error) {
this.destination.error(error);
}
finally {
this.unsubscribe();
}
}
function overrideComplete() {
try {
this._completeOverride();
}
catch (error) {
this.destination.error(error);
}
finally {
this.unsubscribe();
}
}
class ConsumerObserver {
partialObserver;
constructor(partialObserver) {

@@ -114,3 +157,3 @@ this.partialObserver = partialObserver;

function createSafeObserver(observerOrNext) {
return new ConsumerObserver(!observerOrNext || isFunction(observerOrNext) ? { next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined } : observerOrNext);
return new ConsumerObserver(!observerOrNext || isFunction(observerOrNext) ? { next: observerOrNext ?? undefined } : observerOrNext);
}

@@ -124,2 +167,5 @@ function handleStoppedNotification(notification, subscriber) {

}
export function operate({ destination, ...subscriberOverrides }) {
return new Subscriber(destination, subscriberOverrides);
}
//# sourceMappingURL=Subscriber.js.map
import { isFunction } from './util/isFunction';
import { UnsubscriptionError } from './util/UnsubscriptionError';
export class Subscription {
initialTeardown;
static EMPTY = (() => {
const empty = new Subscription();
empty.closed = true;
return empty;
})();
closed = false;
_finalizers = null;
constructor(initialTeardown) {
this.initialTeardown = initialTeardown;
this.closed = false;
this._finalizers = null;
}

@@ -30,3 +36,3 @@ unsubscribe() {

catch (err) {
errors = errors !== null && errors !== void 0 ? errors : [];
errors = errors ?? [];
if (err instanceof UnsubscriptionError) {

@@ -47,3 +53,2 @@ errors.push(...err.errors);

add(teardown) {
var _a;
if (teardown && teardown !== this) {

@@ -59,3 +64,3 @@ if (this.closed) {

}
(_a = this._finalizers) !== null && _a !== void 0 ? _a : (this._finalizers = new Set());
this._finalizers ??= new Set();
this._finalizers.add(teardown);

@@ -66,11 +71,5 @@ }

remove(teardown) {
var _a;
(_a = this._finalizers) === null || _a === void 0 ? void 0 : _a.delete(teardown);
this._finalizers?.delete(teardown);
}
}
Subscription.EMPTY = (() => {
const empty = new Subscription();
empty.closed = true;
return empty;
})();
function execFinalizer(finalizer) {

@@ -77,0 +76,0 @@ if (isFunction(finalizer)) {

@@ -7,2 +7,7 @@ import { Observable } from '../Observable';

export class ColdObservable extends Observable {
messages;
subscriptions = [];
scheduler;
logSubscribedFrame;
logUnsubscribedFrame;
constructor(messages, scheduler) {

@@ -20,3 +25,2 @@ super(function (subscriber) {

this.messages = messages;
this.subscriptions = [];
this.scheduler = scheduler;

@@ -23,0 +27,0 @@ }

@@ -7,6 +7,10 @@ import { Subject } from '../Subject';

export class HotObservable extends Subject {
messages;
subscriptions = [];
scheduler;
logSubscribedFrame;
logUnsubscribedFrame;
constructor(messages, scheduler) {
super();
this.messages = messages;
this.subscriptions = [];
this.scheduler = scheduler;

@@ -13,0 +17,0 @@ }

export class SubscriptionLog {
subscribedFrame;
unsubscribedFrame;
constructor(subscribedFrame, unsubscribedFrame = Infinity) {

@@ -3,0 +5,0 @@ this.subscribedFrame = subscribedFrame;

import { SubscriptionLog } from './SubscriptionLog';
export class SubscriptionLoggable {
constructor() {
this.subscriptions = [];
}
subscriptions = [];
scheduler;
logSubscribedFrame() {

@@ -7,0 +6,0 @@ this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));

@@ -15,9 +15,11 @@ import { Observable } from '../Observable';

export class TestScheduler extends VirtualTimeScheduler {
assertDeepEqual;
static frameTimeFactor = 10;
hotObservables = [];
coldObservables = [];
flushTests = [];
runMode = false;
constructor(assertDeepEqual) {
super(VirtualAction, defaultMaxFrame);
this.assertDeepEqual = assertDeepEqual;
this.hotObservables = [];
this.coldObservables = [];
this.flushTests = [];
this.runMode = false;
}

@@ -505,3 +507,2 @@ createTime(marbles) {

}
TestScheduler.frameTimeFactor = 10;
//# sourceMappingURL=TestScheduler.js.map

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

import { createErrorClass } from './createErrorClass';
export const ArgumentOutOfRangeError = createErrorClass((_super) => function ArgumentOutOfRangeErrorImpl() {
_super(this);
this.name = 'ArgumentOutOfRangeError';
this.message = 'argument out of range';
});
export class ArgumentOutOfRangeError extends Error {
constructor() {
super('argument out of range');
this.name = 'ArgumentOutOfRangeError';
}
}
//# sourceMappingURL=ArgumentOutOfRangeError.js.map

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

import { createErrorClass } from './createErrorClass';
export const EmptyError = createErrorClass((_super) => function EmptyErrorImpl() {
_super(this);
this.name = 'EmptyError';
this.message = 'no elements in sequence';
});
export class EmptyError extends Error {
constructor() {
super('no elements in sequence');
this.name = 'EmptyError';
}
}
//# sourceMappingURL=EmptyError.js.map
import { isFunction } from './isFunction';
export function isAsyncIterable(obj) {
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
return Symbol.asyncIterator && isFunction(obj?.[Symbol.asyncIterator]);
}
//# sourceMappingURL=isAsyncIterable.js.map
import { iterator as Symbol_iterator } from '../symbol/iterator';
import { isFunction } from './isFunction';
export function isIterable(input) {
return isFunction(input === null || input === void 0 ? void 0 : input[Symbol_iterator]);
return isFunction(input?.[Symbol_iterator]);
}
//# sourceMappingURL=isIterable.js.map
import { isFunction } from "./isFunction";
export function isPromise(value) {
return isFunction(value === null || value === void 0 ? void 0 : value.then);
return isFunction(value?.then);
}
//# sourceMappingURL=isPromise.js.map

@@ -1,23 +0,20 @@

import { __asyncGenerator, __await } from "tslib";
import { isFunction } from './isFunction';
export function readableStreamLikeToAsyncGenerator(readableStream) {
return __asyncGenerator(this, arguments, function* readableStreamLikeToAsyncGenerator_1() {
const reader = readableStream.getReader();
try {
while (true) {
const { value, done } = yield __await(reader.read());
if (done) {
return yield __await(void 0);
}
yield yield __await(value);
export async function* readableStreamLikeToAsyncGenerator(readableStream) {
const reader = readableStream.getReader();
try {
while (true) {
const { value, done } = await reader.read();
if (done) {
return;
}
yield value;
}
finally {
reader.releaseLock();
}
});
}
finally {
reader.releaseLock();
}
}
export function isReadableStreamLike(obj) {
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
return isFunction(obj?.getReader);
}
//# sourceMappingURL=isReadableStreamLike.js.map

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

import { createErrorClass } from './createErrorClass';
export const NotFoundError = createErrorClass((_super) => function NotFoundErrorImpl(message) {
_super(this);
this.name = 'NotFoundError';
this.message = message;
});
export class NotFoundError extends Error {
constructor(message) {
super(message);
this.name = 'NotFoundError';
}
}
//# sourceMappingURL=NotFoundError.js.map

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

import { createErrorClass } from './createErrorClass';
export const SequenceError = createErrorClass((_super) => function SequenceErrorImpl(message) {
_super(this);
this.name = 'SequenceError';
this.message = message;
});
export class SequenceError extends Error {
constructor(message) {
super(message);
this.name = 'SequenceError';
}
}
//# sourceMappingURL=SequenceError.js.map

@@ -1,11 +0,12 @@

import { createErrorClass } from './createErrorClass';
export const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
_super(this);
this.message = errors
? `${errors.length} errors occurred during unsubscription:
export class UnsubscriptionError extends Error {
errors;
constructor(errors) {
super(errors
? `${errors.length} errors occurred during unsubscription:
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
: '';
this.name = 'UnsubscriptionError';
this.errors = errors;
});
: '');
this.errors = errors;
this.name = 'UnsubscriptionError';
}
}
//# sourceMappingURL=UnsubscriptionError.js.map

@@ -19,3 +19,4 @@ /// <reference path="operators/index.d.ts" />

export { Subscription } from './internal/Subscription';
export { Subscriber } from './internal/Subscriber';
export { Subscriber, SubscriberOverrides } from './internal/Subscriber';
export { rx } from './internal/util/rx';
export { pipe } from './internal/util/pipe';

@@ -25,2 +26,3 @@ export { noop } from './internal/util/noop';

export { isObservable } from './internal/util/isObservable';
export { operate } from './internal/Subscriber';
export { lastValueFrom } from './internal/lastValueFrom';

@@ -27,0 +29,0 @@ export { firstValueFrom } from './internal/firstValueFrom';

import { AjaxRequest } from './types';
/**
* A normalized AJAX error.
* Thrown when an error occurs during an AJAX request.
* This is only exported because it is useful for checking to see if an error
* is an `instanceof AjaxError`. DO NOT create new instances of `AjaxError` with
* the constructor.
*
* @see {@link ajax}
*/
export interface AjaxError extends Error {
export declare class AjaxError extends Error {
/**
* The XHR instance associated with the error.
*/
xhr: XMLHttpRequest;
readonly xhr: XMLHttpRequest;
/**
* The AjaxRequest associated with the error.
*/
request: AjaxRequest;
readonly request: AjaxRequest;
/**

@@ -20,13 +23,11 @@ * The HTTP status code, if the request has completed. If not,

*/
status: number;
readonly status: number;
/**
* The responseType (e.g. 'json', 'arraybuffer', or 'xml').
*/
responseType: XMLHttpRequestResponseType;
readonly responseType: XMLHttpRequestResponseType;
/**
* The response data.
*/
response: any;
}
export interface AjaxErrorCtor {
readonly response: any;
/**

@@ -36,16 +37,14 @@ * @deprecated Internal implementation detail. Do not construct error instances.

*/
new (message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError;
constructor(message: string, xhr: XMLHttpRequest, request: AjaxRequest);
}
/**
* Thrown when an error occurs during an AJAX request.
* This is only exported because it is useful for checking to see if an error
* is an `instanceof AjaxError`. DO NOT create new instances of `AjaxError` with
* the constructor.
* Thrown when an AJAX request times out. Not to be confused with {@link TimeoutError}.
*
* This is exported only because it is useful for checking to see if errors are an
* `instanceof AjaxTimeoutError`. DO NOT use the constructor to create an instance of
* this type.
*
* @see {@link ajax}
*/
export declare const AjaxError: AjaxErrorCtor;
export interface AjaxTimeoutError extends AjaxError {
}
export interface AjaxTimeoutErrorCtor {
export declare class AjaxTimeoutError extends AjaxError {
/**

@@ -55,14 +54,4 @@ * @deprecated Internal implementation detail. Do not construct error instances.

*/
new (xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError;
constructor(xhr: XMLHttpRequest, request: AjaxRequest);
}
/**
* Thrown when an AJAX request times out. Not to be confused with {@link TimeoutError}.
*
* This is exported only because it is useful for checking to see if errors are an
* `instanceof AjaxTimeoutError`. DO NOT use the constructor to create an instance of
* this type.
*
* @see {@link ajax}
*/
export declare const AjaxTimeoutError: AjaxTimeoutErrorCtor;
//# sourceMappingURL=errors.d.ts.map
import { Subscriber } from './Subscriber';
import { Subscription } from './Subscription';
import { TeardownLogic, OperatorFunction, Subscribable, Observer } from './types';
import { TeardownLogic, UnaryFunction, Subscribable, Observer, OperatorFunction } from './types';
/**

@@ -194,12 +194,13 @@ * A representation of any set of values over any amount of time. This is the most basic building block

pipe(): Observable<T>;
pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;
pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;
pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;
pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>;
pipe<A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): Observable<E>;
pipe<A, B, C, D, E, F>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): Observable<F>;
pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): Observable<G>;
pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): Observable<H>;
pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): Observable<I>;
pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<unknown>;
pipe<A>(op1: UnaryFunction<Observable<T>, A>): A;
pipe<A, B>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>): B;
pipe<A, B, C>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>): C;
pipe<A, B, C, D>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>): D;
pipe<A, B, C, D, E>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>): E;
pipe<A, B, C, D, E, F>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>): F;
pipe<A, B, C, D, E, F, G>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>): G;
pipe<A, B, C, D, E, F, G, H>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>): H;
pipe<A, B, C, D, E, F, G, H, I>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>): I;
pipe<A, B, C, D, E, F, G, H, I>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<unknown>;
pipe<A, B, C, D, E, F, G, H, I>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>, ...operations: UnaryFunction<any, any>[]): unknown;
/**

@@ -206,0 +207,0 @@ * Observable is async iterable, so it can be used in `for await` loop. This method

@@ -20,3 +20,3 @@ import { Observable } from '../Observable';

}>;
export declare function combineLatestInit(observables: ObservableInput<any>[], valueTransform?: (values: any[]) => any): (subscriber: Subscriber<any>) => void;
export declare function combineLatestInit(observables: ObservableInput<any>[], valueTransform?: (values: any[]) => any): (destination: Subscriber<any>) => void;
//# sourceMappingURL=combineLatest.d.ts.map

@@ -82,2 +82,3 @@ import { Observable } from '../Observable';

export declare function fromArrayLike<T>(array: ArrayLike<T>): Observable<T>;
export declare function fromPromise<T>(promise: PromiseLike<T>): Observable<T>;
/**

@@ -84,0 +85,0 @@ * Subscribes to an ArrayLike with a subscriber

@@ -11,3 +11,3 @@ import { Observable } from '../Observable';

*/
export declare function raceInit<T>(sources: ObservableInput<T>[]): (subscriber: Subscriber<T>) => void;
export declare function raceInit<T>(sources: ObservableInput<T>[]): (destination: Subscriber<T>) => void;
//# sourceMappingURL=race.d.ts.map

@@ -7,3 +7,3 @@ import { Observable } from '../Observable';

export declare function find<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean): OperatorFunction<T, T | undefined>;
export declare function createFind<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, emit: 'value' | 'index', source: Observable<T>, subscriber: Subscriber<any>): void;
export declare function createFind<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, emit: 'value' | 'index', source: Observable<T>, destination: Subscriber<any>): void;
//# sourceMappingURL=find.d.ts.map

@@ -8,3 +8,3 @@ import { Observable } from '../Observable';

* @param source The original source observable
* @param subscriber The consumer subscriber
* @param destination The consumer subscriber
* @param project The projection function to get our inner sources

@@ -18,3 +18,3 @@ * @param concurrent The number of concurrent inner subscriptions

*/
export declare function mergeInternals<T, R>(source: Observable<T>, subscriber: Subscriber<R>, project: (value: T, index: number) => ObservableInput<R>, concurrent: number, onBeforeNext?: (innerValue: R) => void, expand?: boolean, innerSubScheduler?: SchedulerLike, additionalFinalizer?: () => void): () => void;
export declare function mergeInternals<T, R>(source: Observable<T>, destination: Subscriber<R>, project: (value: T, index: number) => ObservableInput<R>, concurrent: number, onBeforeNext?: (innerValue: R) => void, expand?: boolean, innerSubScheduler?: SchedulerLike, additionalFinalizer?: () => void): () => void;
//# sourceMappingURL=mergeInternals.d.ts.map

@@ -11,3 +11,3 @@ import { Observable } from '../Observable';

*/
export declare function scanInternals<V, A, S>(accumulator: (acc: V | A | S, value: V, index: number) => A, seed: S, hasSeed: boolean, emitOnNext: boolean, emitBeforeComplete: boolean, source: Observable<V>, subscriber: Subscriber<any>): void;
export declare function scanInternals<V, A, S>(accumulator: (acc: V | A | S, value: V, index: number) => A, seed: S, hasSeed: boolean, emitOnNext: boolean, emitBeforeComplete: boolean, source: Observable<V>, destination: Subscriber<any>): void;
//# sourceMappingURL=scanInternals.d.ts.map

@@ -1,7 +0,5 @@

import { OperatorFunction, SchedulerLike, ValueFromArray } from '../types';
import { OperatorFunction, ValueFromArray } from '../types';
export declare function startWith<T>(value: null): OperatorFunction<T, T | null>;
export declare function startWith<T>(value: undefined): OperatorFunction<T, T | undefined>;
/** @deprecated The `scheduler` parameter will be removed in v8. Use `scheduled` and `concatAll`. Details: https://rxjs.dev/deprecations/scheduler-argument */
export declare function startWith<T, A extends readonly unknown[] = T[]>(...valuesAndScheduler: [...A, SchedulerLike]): OperatorFunction<T, T | ValueFromArray<A>>;
export declare function startWith<T, A extends readonly unknown[] = T[]>(...values: A): OperatorFunction<T, T | ValueFromArray<A>>;
//# sourceMappingURL=startWith.d.ts.map

@@ -39,7 +39,15 @@ import { MonoTypeOperatorFunction, SchedulerLike, OperatorFunction, ObservableInput, ObservedValueOf } from '../types';

/**
* An error emitted when a timeout occurs.
* An error thrown by the {@link timeout} operator.
*
* Provided so users can use as a type and do quality comparisons.
* We recommend you do not subclass this or create instances of this class directly.
* If you have need of a error representing a timeout, you should
* create your own error class and use that.
*
* @see {@link timeout}
*/
export interface TimeoutError<T = unknown, M = unknown> extends Error {
export declare class TimeoutError<T, M> extends Error {
info: TimeoutInfo<T, M> | null;
/**
* The information provided to the error by the timeout
* @param info The information provided to the error by the timeout
* operation that created the error. Will be `null` if

@@ -49,24 +57,8 @@ * used directly in non-RxJS code with an empty constructor.

* you should create your own errors)
*/
info: TimeoutInfo<T, M> | null;
}
export interface TimeoutErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new <T = unknown, M = unknown>(info?: TimeoutInfo<T, M>): TimeoutError<T, M>;
constructor(info?: TimeoutInfo<T, M> | null);
}
/**
* An error thrown by the {@link timeout} operator.
*
* Provided so users can use as a type and do quality comparisons.
* We recommend you do not subclass this or create instances of this class directly.
* If you have need of a error representing a timeout, you should
* create your own error class and use that.
*
* @see {@link timeout}
*/
export declare const TimeoutError: TimeoutErrorCtor;
/**
* If `with` is provided, this will return an observable that will switch to a different observable if the source

@@ -73,0 +65,0 @@ * does not push values within the specified time parameters.

import { Observer } from './types';
import { Subscription } from './Subscription';
export interface SubscriberOverrides<T> {
/**
* If provided, this function will be called whenever the {@link Subscriber}'s
* `next` method is called, with the value that was passed to that call. If
* an error is thrown within this function, it will be handled and passed to
* the destination's `error` method.
* @param value The value that is being observed from the source.
*/
next?: (value: T) => void;
/**
* If provided, this function will be called whenever the {@link Subscriber}'s
* `error` method is called, with the error that was passed to that call. If
* an error is thrown within this function, it will be handled and passed to
* the destination's `error` method.
* @param err An error that has been thrown by the source observable.
*/
error?: (err: any) => void;
/**
* If provided, this function will be called whenever the {@link Subscriber}'s
* `complete` method is called. If an error is thrown within this function, it
* will be handled and passed to the destination's `error` method.
*/
complete?: () => void;
/**
* If provided, this function will be called after all teardown has occurred
* for this {@link Subscriber}. This is generally used for cleanup purposes
* during operator development.
*/
finalize?: () => void;
}
/**

@@ -13,12 +43,3 @@ * Implements the {@link Observer} interface and extends the

/**
* Creates an instance of an RxJS Subscriber. This is the workhorse of the library.
*
* If another instance of Subscriber is passed in, it will automatically wire up unsubscription
* between this instnace and the passed in instance.
*
* If a partial or full observer is passed in, it will be wrapped and appropriate safeguards will be applied.
*
* If a next-handler function is passed in, it will be wrapped and appropriate safeguards will be applied.
*
* @param destination A subscriber, partial observer, or function that receives the next value.
* @deprecated Do not create instances of `Subscriber` directly. Use {@link operate} instead.
*/

@@ -51,2 +72,31 @@ constructor(destination?: Subscriber<T> | Partial<Observer<T>> | ((value: T) => void) | null);

}
export interface OperateConfig<In, Out> extends SubscriberOverrides<In> {
/**
* The destination subscriber to forward notifications to. This is also the
* subscriber that will receive unhandled errors if your `next`, `error`, or `complete`
* overrides throw.
*/
destination: Subscriber<Out>;
}
/**
* Creates a new {@link Subscriber} instance that passes notifications on to the
* supplied `destination`. The overrides provided in the `config` argument for
* `next`, `error`, and `complete` will be called in such a way that any
* errors are caught and forwarded to the destination's `error` handler. The returned
* `Subscriber` will be "chained" to the `destination` such that when `unsubscribe` is
* called on the `destination`, the returned `Subscriber` will also be unsubscribed.
*
* Advanced: This ensures that subscriptions are properly wired up prior to starting the
* subcription logic. This prevents "synchronous firehose" scenarios where an
* inner observable from a flattening operation cannot be stopped by a downstream
* terminal operator like `take`.
*
* This is a utility designed to be used to create new operators for observables.
*
* For examples, please see our code base.
*
* @param config The configuration for creating a new subscriber for an operator.
* @returns A new subscriber that is chained to the destination.
*/
export declare function operate<In, Out>({ destination, ...subscriberOverrides }: OperateConfig<In, Out>): Subscriber<In>;
//# sourceMappingURL=Subscriber.d.ts.map

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

export interface ArgumentOutOfRangeError extends Error {
}
export interface ArgumentOutOfRangeErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (): ArgumentOutOfRangeError;
}
/**

@@ -18,3 +9,9 @@ * An error thrown when an element was queried at a certain index of an

*/
export declare const ArgumentOutOfRangeError: ArgumentOutOfRangeErrorCtor;
export declare class ArgumentOutOfRangeError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor();
}
//# sourceMappingURL=ArgumentOutOfRangeError.d.ts.map

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

export interface EmptyError extends Error {
}
export interface EmptyErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (): EmptyError;
}
/**

@@ -20,3 +11,9 @@ * An error thrown when an Observable or a sequence was queried but has no

*/
export declare const EmptyError: EmptyErrorCtor;
export declare class EmptyError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor();
}
//# sourceMappingURL=EmptyError.d.ts.map

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

export interface NotFoundError extends Error {
}
export interface NotFoundErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (message: string): NotFoundError;
}
/**

@@ -16,3 +7,9 @@ * An error thrown when a value or values are missing from an

*/
export declare const NotFoundError: NotFoundErrorCtor;
export declare class NotFoundError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor(message: string);
}
//# sourceMappingURL=NotFoundError.d.ts.map

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

export interface SequenceError extends Error {
}
export interface SequenceErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (message: string): SequenceError;
}
/**

@@ -16,3 +7,9 @@ * An error thrown when something is wrong with the sequence of

*/
export declare const SequenceError: SequenceErrorCtor;
export declare class SequenceError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor(message: string);
}
//# sourceMappingURL=SequenceError.d.ts.map

@@ -1,5 +0,7 @@

export interface UnsubscriptionError extends Error {
readonly errors: any[];
}
export interface UnsubscriptionErrorCtor {
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
export declare class UnsubscriptionError extends Error {
errors: any[];
/**

@@ -9,9 +11,4 @@ * @deprecated Internal implementation detail. Do not construct error instances.

*/
new (errors: any[]): UnsubscriptionError;
constructor(errors: any[]);
}
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
export declare const UnsubscriptionError: UnsubscriptionErrorCtor;
//# sourceMappingURL=UnsubscriptionError.d.ts.map

@@ -5,5 +5,4 @@ {

"main": "../dist/cjs/fetch/index.js",
"module": "../dist/esm5/fetch/index.js",
"es2015": "../dist/esm/fetch/index.js",
"module": "../dist/esm/fetch/index.js",
"sideEffects": false
}

@@ -5,5 +5,4 @@ {

"main": "../dist/cjs/operators/index.js",
"module": "../dist/esm5/operators/index.js",
"es2015": "../dist/esm/operators/index.js",
"module": "../dist/esm/operators/index.js",
"sideEffects": false
}
{
"name": "rxjs",
"version": "8.0.0-alpha.9",
"version": "8.0.0-alpha.10",
"description": "Reactive Extensions for modern JavaScript",
"main": "./dist/cjs/index.js",
"module": "./dist/esm5/index.js",
"es2015": "./dist/esm/index.js",
"module": "./dist/esm/index.js",
"types": "index.d.ts",

@@ -22,4 +21,3 @@ "typesVersions": {

"require": "./dist/cjs/index.js",
"es2015": "./dist/esm/index.js",
"default": "./dist/esm5/index.js"
"default": "./dist/esm/index.js"
},

@@ -30,4 +28,3 @@ "./ajax": {

"require": "./dist/cjs/ajax/index.js",
"es2015": "./dist/esm/ajax/index.js",
"default": "./dist/esm5/ajax/index.js"
"default": "./dist/esm/ajax/index.js"
},

@@ -38,4 +35,3 @@ "./fetch": {

"require": "./dist/cjs/fetch/index.js",
"es2015": "./dist/esm/fetch/index.js",
"default": "./dist/esm5/fetch/index.js"
"default": "./dist/esm/fetch/index.js"
},

@@ -46,4 +42,3 @@ "./operators": {

"require": "./dist/cjs/operators/index.js",
"es2015": "./dist/esm/operators/index.js",
"default": "./dist/esm5/operators/index.js"
"default": "./dist/esm/operators/index.js"
},

@@ -54,4 +49,3 @@ "./testing": {

"require": "./dist/cjs/testing/index.js",
"es2015": "./dist/esm/testing/index.js",
"default": "./dist/esm5/testing/index.js"
"default": "./dist/esm/testing/index.js"
},

@@ -62,4 +56,3 @@ "./webSocket": {

"require": "./dist/cjs/webSocket/index.js",
"es2015": "./dist/esm/webSocket/index.js",
"default": "./dist/esm5/webSocket/index.js"
"default": "./dist/esm/webSocket/index.js"
},

@@ -70,4 +63,3 @@ "./internal/*": {

"require": "./dist/cjs/internal/*.js",
"es2015": "./dist/esm/internal/*.js",
"default": "./dist/esm5/internal/*.js"
"default": "./dist/esm/internal/*.js"
},

@@ -91,3 +83,2 @@ "./package.json": "./package.json"

"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
"build:spec:browser": "echo \"Browser test is not working currently\" && exit -1 && webpack --config spec/support/webpack.mocha.config.js",
"lint_spec": "tslint -c spec/tslint.json -p spec/tsconfig.json \"spec/**/*.ts\"",

@@ -97,16 +88,11 @@ "lint_src": "tslint -c tslint.json -p src/tsconfig.base.json \"src/**/*.ts\"",

"dtslint": "tsc -b ./src/tsconfig.types.json && tslint -c spec-dtslint/tslint.json -p spec-dtslint/tsconfig.json \"spec-dtslint/**/*.ts\"",
"prepublishOnly": "npm run build:package && npm run lint && npm run test && npm run test:circular && npm run dtslint && npm run test:side-effects",
"prepublishOnly": "npm run build:package && npm run lint && npm run test && npm run test:circular && npm run dtslint",
"publish_docs": "./publish_docs.sh",
"test": "cross-env TS_NODE_PROJECT=tsconfig.mocha.json mocha --config spec/support/.mocharc.js \"spec/**/*-spec.ts\"",
"test:esm": "node spec/module-test-spec.mjs",
"test:browser": "echo \"Browser test is not working currently\" && exit -1 && npm-run-all build:spec:browser && opn spec/support/mocha-browser-runner.html",
"test:circular": "dependency-cruiser --validate .dependency-cruiser.json -x \"^node_modules\" dist/esm5",
"test:systemjs": "node integration/systemjs/systemjs-compatibility-spec.js",
"test:side-effects": "check-side-effects --test integration/side-effects/side-effects.json",
"test:side-effects:update": "npm run test:side-effects -- --update",
"test:circular": "dependency-cruiser --validate .dependency-cruiser.json -x \"^node_modules\" dist/esm",
"test:import": "ts-node ./integration/import/runner.ts",
"compile": "tsc -b ./src/tsconfig.cjs.json ./src/tsconfig.cjs.spec.json ./src/tsconfig.esm.json ./src/tsconfig.esm5.json ./src/tsconfig.esm5.rollup.json ./src/tsconfig.types.json ./src/tsconfig.types.spec.json ./spec/tsconfig.json",
"compile": "tsc -b ./src/tsconfig.cjs.json ./src/tsconfig.cjs.spec.json ./src/tsconfig.esm.json ./src/tsconfig.types.json ./src/tsconfig.types.spec.json ./spec/tsconfig.json",
"build:clean": "shx rm -rf ./dist",
"build:global": "node ./tools/make-umd-bundle.js && node ./tools/make-closure-core.js",
"build:package": "npm-run-all build:clean compile build:global && node ./tools/prepare-package.js && node ./tools/generate-alias.js",
"build:package": "npm-run-all build:clean compile && node ./tools/generate-alias.js",
"watch": "nodemon -w \"src/\" -w \"spec/\" -e ts -x npm test",

@@ -127,5 +113,3 @@ "watch:dtslint": "nodemon -w \"src/\" -w \"spec-dtslint/\" -e ts -x npm run dtslint"

"Observable",
"Stream",
"ES6",
"ES2015"
"Stream"
],

@@ -164,5 +148,2 @@ "author": "Ben Lesh <ben@benlesh.com>",

"homepage": "https://rxjs.dev",
"dependencies": {
"tslib": "^2.1.0"
},
"devDependencies": {

@@ -185,3 +166,2 @@ "@angular-devkit/build-optimizer": "0.4.6",

"chai": "^4.3.7",
"check-side-effects": "0.0.23",
"color": "3.0.0",

@@ -197,4 +177,2 @@ "colors": "1.1.2",

"fs-extra": "^8.1.0",
"glob": "7.1.2",
"google-closure-compiler-js": "20170218.0.0",
"husky": "^4.2.5",

@@ -208,10 +186,3 @@ "klaw-sync": "3.0.2",

"npm-run-all": "4.1.2",
"opn-cli": "3.1.0",
"platform": "1.3.5",
"prettier": "^2.5.1",
"promise": "8.0.1",
"rollup": "0.66.6",
"rollup-plugin-alias": "1.4.0",
"rollup-plugin-inject": "2.0.0",
"rollup-plugin-node-resolve": "2.0.0",
"shelljs": "^0.8.4",

@@ -222,3 +193,2 @@ "shx": "^0.3.2",

"source-map-support": "0.5.3",
"systemjs": "^0.21.0",
"ts-node": "^10.9.1",

@@ -232,10 +202,7 @@ "tslint": "^5.20.1",

"validate-commit-msg": "2.14.0",
"web-streams-polyfill": "^3.0.2",
"webpack": "^4.31.0"
"web-streams-polyfill": "^3.0.2"
},
"files": [
"dist/bundles",
"dist/cjs/**/!(*.tsbuildinfo)",
"dist/esm/**/!(*.tsbuildinfo)",
"dist/esm5/**/!(*.tsbuildinfo)",
"dist/types/**/!(*.tsbuildinfo)",

@@ -242,0 +209,0 @@ "ajax",

@@ -48,6 +48,6 @@ # <img src="docs_app/src/assets/images/logos/Rx_Logo_S.png" alt="RxJS Logo" width="86" height="86"> RxJS: Reactive Extensions For JavaScript

.pipe(
filter(x => x % 2 === 1),
map(x => x + x)
filter((x) => x % 2 === 1),
map((x) => x + x)
)
.subscribe(x => console.log(x));
.subscribe((x) => console.log(x));
```

@@ -63,28 +63,8 @@

.pipe(
filter(x => x % 2 === 1),
map(x => x + x)
filter((x) => x % 2 === 1),
map((x) => x + x)
)
.subscribe(x => console.log(x));
.subscribe((x) => console.log(x));
```
### CDN
For CDN, you can use [unpkg](https://unpkg.com/):
[https://unpkg.com/rxjs@^7/dist/bundles/rxjs.umd.min.js](https://unpkg.com/rxjs@%5E7/dist/bundles/rxjs.umd.min.js)
The global namespace for rxjs is `rxjs`:
```js
const { range } = rxjs;
const { filter, map } = rxjs.operators;
range(1, 200)
.pipe(
filter(x => x % 2 === 1),
map(x => x + x)
)
.subscribe(x => console.log(x));
```
## Goals

@@ -91,0 +71,0 @@

@@ -38,5 +38,6 @@ //////////////////////////////////////////////////////////

export { Subscription } from './internal/Subscription';
export { Subscriber } from './internal/Subscriber';
export { Subscriber, SubscriberOverrides } from './internal/Subscriber';
/* Utils */
export { rx } from './internal/util/rx';
export { pipe } from './internal/util/pipe';

@@ -46,2 +47,3 @@ export { noop } from './internal/util/noop';

export { isObservable } from './internal/util/isObservable';
export { operate } from './internal/Subscriber';

@@ -48,0 +50,0 @@ /* Promise Conversion */

import { AjaxRequest } from './types';
import { createErrorClass } from '../util/createErrorClass';
/**
* A normalized AJAX error.
* Thrown when an error occurs during an AJAX request.
* This is only exported because it is useful for checking to see if an error
* is an `instanceof AjaxError`. DO NOT create new instances of `AjaxError` with
* the constructor.
*
* @see {@link ajax}
*/
export interface AjaxError extends Error {
export class AjaxError extends Error {
/**
* The XHR instance associated with the error.
*/
xhr: XMLHttpRequest;
readonly xhr: XMLHttpRequest;

@@ -18,3 +20,3 @@ /**

*/
request: AjaxRequest;
readonly request: AjaxRequest;

@@ -25,3 +27,3 @@ /**

*/
status: number;
readonly status: number;

@@ -31,3 +33,3 @@ /**

*/
responseType: XMLHttpRequestResponseType;
readonly responseType: XMLHttpRequestResponseType;

@@ -37,6 +39,4 @@ /**

*/
response: any;
}
readonly response: any;
export interface AjaxErrorCtor {
/**

@@ -46,37 +46,14 @@ * @deprecated Internal implementation detail. Do not construct error instances.

*/
new (message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError;
constructor(message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
super(message);
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType;
this.response = xhr.response;
}
}
/**
* Thrown when an error occurs during an AJAX request.
* This is only exported because it is useful for checking to see if an error
* is an `instanceof AjaxError`. DO NOT create new instances of `AjaxError` with
* the constructor.
*
* @see {@link ajax}
*/
export const AjaxError: AjaxErrorCtor = createErrorClass(
(_super) =>
function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
this.message = message;
this.name = 'AjaxError';
this.xhr = xhr;
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType;
this.response = xhr.response;
}
);
export interface AjaxTimeoutError extends AjaxError {}
export interface AjaxTimeoutErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError;
}
/**
* Thrown when an AJAX request times out. Not to be confused with {@link TimeoutError}.

@@ -90,10 +67,11 @@ *

*/
export const AjaxTimeoutError: AjaxTimeoutErrorCtor = (() => {
function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) {
AjaxError.call(this, 'ajax timeout', xhr, request);
export class AjaxTimeoutError extends AjaxError {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor(xhr: XMLHttpRequest, request: AjaxRequest) {
super('ajax timeout', xhr, request);
this.name = 'AjaxTimeoutError';
return this;
}
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
return AjaxTimeoutErrorImpl;
})() as any;
}
import { Subscriber } from './Subscriber';
import { Subscription } from './Subscription';
import { TeardownLogic, OperatorFunction, Subscribable, Observer } from './types';
import { TeardownLogic, UnaryFunction, Subscribable, Observer, OperatorFunction } from './types';
import { observable as Symbol_observable } from './symbol/observable';
import { pipeFromArray } from './util/pipe';
/**

@@ -250,68 +249,75 @@ * A representation of any set of values over any amount of time. This is the most basic building block

pipe(): Observable<T>;
pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;
pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;
pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;
pipe<A, B, C, D>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>
): Observable<D>;
pipe<A>(op1: UnaryFunction<Observable<T>, A>): A;
pipe<A, B>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>): B;
pipe<A, B, C>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>): C;
pipe<A, B, C, D>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>): D;
pipe<A, B, C, D, E>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>,
op5: OperatorFunction<D, E>
): Observable<E>;
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>
): E;
pipe<A, B, C, D, E, F>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>,
op5: OperatorFunction<D, E>,
op6: OperatorFunction<E, F>
): Observable<F>;
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>,
op6: UnaryFunction<E, F>
): F;
pipe<A, B, C, D, E, F, G>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>,
op5: OperatorFunction<D, E>,
op6: OperatorFunction<E, F>,
op7: OperatorFunction<F, G>
): Observable<G>;
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>,
op6: UnaryFunction<E, F>,
op7: UnaryFunction<F, G>
): G;
pipe<A, B, C, D, E, F, G, H>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>,
op5: OperatorFunction<D, E>,
op6: OperatorFunction<E, F>,
op7: OperatorFunction<F, G>,
op8: OperatorFunction<G, H>
): Observable<H>;
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>,
op6: UnaryFunction<E, F>,
op7: UnaryFunction<F, G>,
op8: UnaryFunction<G, H>
): H;
pipe<A, B, C, D, E, F, G, H, I>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>,
op5: OperatorFunction<D, E>,
op6: OperatorFunction<E, F>,
op7: OperatorFunction<F, G>,
op8: OperatorFunction<G, H>,
op9: OperatorFunction<H, I>
): Observable<I>;
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>,
op6: UnaryFunction<E, F>,
op7: UnaryFunction<F, G>,
op8: UnaryFunction<G, H>,
op9: UnaryFunction<H, I>
): I;
pipe<A, B, C, D, E, F, G, H, I>(
op1: OperatorFunction<T, A>,
op2: OperatorFunction<A, B>,
op3: OperatorFunction<B, C>,
op4: OperatorFunction<C, D>,
op5: OperatorFunction<D, E>,
op6: OperatorFunction<E, F>,
op7: OperatorFunction<F, G>,
op8: OperatorFunction<G, H>,
op9: OperatorFunction<H, I>,
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>,
op6: UnaryFunction<E, F>,
op7: UnaryFunction<F, G>,
op8: UnaryFunction<G, H>,
op9: UnaryFunction<H, I>,
...operations: OperatorFunction<any, any>[]
): Observable<unknown>;
pipe<A, B, C, D, E, F, G, H, I>(
op1: UnaryFunction<Observable<T>, A>,
op2: UnaryFunction<A, B>,
op3: UnaryFunction<B, C>,
op4: UnaryFunction<C, D>,
op5: UnaryFunction<D, E>,
op6: UnaryFunction<E, F>,
op7: UnaryFunction<F, G>,
op8: UnaryFunction<G, H>,
op9: UnaryFunction<H, I>,
...operations: UnaryFunction<any, any>[]
): unknown;
/* tslint:enable:max-line-length */

@@ -339,3 +345,3 @@

*/
pipe(...operations: OperatorFunction<any, any>[]): Observable<any> {
pipe(...operations: UnaryFunction<any, any>[]): unknown {
return pipeFromArray(operations)(this);

@@ -342,0 +348,0 @@ }

import { Observable } from '../Observable';
import { ObservableInput, ObservedValueOf, ObservableInputTuple } from '../types';
import { arrayOrObject } from '../util/argsArgArrayOrObject';
import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { identity } from '../util/identity';
import { createObject } from '../util/createObject';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { AnyCatcher } from '../AnyCatcher';

@@ -199,3 +198,3 @@ import { EMPTY } from './empty';

export function combineLatestInit(observables: ObservableInput<any>[], valueTransform: (values: any[]) => any = identity) {
return (subscriber: Subscriber<any>) => {
return (destination: Subscriber<any>) => {
const { length } = observables;

@@ -217,5 +216,5 @@ // A store for the values each observable has emitted so far. We match observable to value on index.

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
// When we get a value, record it in our set of values.

@@ -231,13 +230,13 @@ values[i] = value;

// first values, so we can emit!
subscriber.next(valueTransform(Array.from(values)));
destination.next(valueTransform(Array.from(values)));
}
},
() => {
complete: () => {
if (!--active) {
// We only complete the result if we have no more active
// inner observables.
subscriber.complete();
destination.complete();
}
}
)
},
})
);

@@ -244,0 +243,0 @@ }

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

import { createOperatorSubscriber } from '../../operators/OperatorSubscriber';
import { operate } from '../../Subscriber';
import { Observable } from '../../Observable';

@@ -102,3 +102,3 @@ import { from } from '../from';

const { selector, ...init } = initWithSelector;
return new Observable<Response | T>((subscriber) => {
return new Observable<Response | T>((destination) => {
// Our controller for aborting this fetch.

@@ -132,3 +132,3 @@ // Any externally provided AbortSignal will have to call

outerSignal.addEventListener('abort', outerSignalHandler);
subscriber.add(() => outerSignal.removeEventListener('abort', outerSignalHandler));
destination.add(() => outerSignal.removeEventListener('abort', outerSignalHandler));
}

@@ -146,3 +146,3 @@ }

abortable = false;
subscriber.error(err);
destination.error(err);
};

@@ -157,18 +157,16 @@

from(selector(response)).subscribe(
createOperatorSubscriber(
subscriber,
// Values are passed through to the subscriber
undefined,
operate({
destination,
// The projected response is complete.
() => {
complete: () => {
abortable = false;
subscriber.complete();
destination.complete();
},
handleError
)
error: handleError,
})
);
} else {
abortable = false;
subscriber.next(response);
subscriber.complete();
destination.next(response);
destination.complete();
}

@@ -175,0 +173,0 @@ })

@@ -6,6 +6,7 @@ import { Observable } from '../Observable';

import { popResultSelector } from '../util/args';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
import { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';
import { createObject } from '../util/createObject';
import { AnyCatcher } from '../AnyCatcher';
import { EmptyError } from '../util/EmptyError';

@@ -149,6 +150,6 @@ // forkJoin(any)

const { args: sources, keys } = argsArgArrayOrObject(args);
const result = new Observable((subscriber) => {
const result = new Observable((destination) => {
const { length } = sources;
if (!length) {
subscriber.complete();
destination.complete();
return;

@@ -162,5 +163,5 @@ }

from(sources[sourceIndex]).subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
if (!hasValue) {

@@ -172,13 +173,14 @@ hasValue = true;

},
() => remainingCompletions--,
undefined,
() => {
complete: () => remainingCompletions--,
finalize: () => {
if (!remainingCompletions || !hasValue) {
if (!remainingEmissions) {
subscriber.next(keys ? createObject(keys, values) : values);
if (remainingEmissions === 0) {
destination.next(keys ? createObject(keys, values) : values);
destination.complete();
} else {
destination.error(new EmptyError());
}
subscriber.complete();
}
}
)
},
})
);

@@ -185,0 +187,0 @@ }

@@ -142,3 +142,3 @@ import { isArrayLike } from '../util/isArrayLike';

function fromPromise<T>(promise: PromiseLike<T>) {
export function fromPromise<T>(promise: PromiseLike<T>) {
return new Observable((subscriber: Subscriber<T>) => {

@@ -209,3 +209,6 @@ promise

const length = array.length;
for (let i = 0; i < length && !subscriber.closed; i++) {
for (let i = 0; i < length; i++) {
if (subscriber.closed) {
return;
}
subscriber.next(array[i]);

@@ -212,0 +215,0 @@ }

import { Observable } from '../Observable';
import { ObservableInputTuple } from '../types';
import { argsOrArgArray } from '../util/argsOrArgArray';
import { OperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';

@@ -78,3 +78,3 @@ import { from } from './from';

return new Observable((subscriber) => {
return new Observable((destination) => {
let sourceIndex = 0;

@@ -90,7 +90,7 @@ const subscribeNext = () => {

}
const innerSubscriber = new OperatorSubscriber(subscriber, undefined, noop, noop);
const innerSubscriber = operate({ destination, error: noop, complete: noop });
nextSource.subscribe(innerSubscriber);
innerSubscriber.add(subscribeNext);
} else {
subscriber.complete();
destination.complete();
}

@@ -97,0 +97,0 @@ };

@@ -6,4 +6,3 @@ import { Observable } from '../Observable';

import { argsOrArgArray } from '../util/argsOrArgArray';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';

@@ -64,3 +63,3 @@ export function race<T extends readonly unknown[]>(inputs: [...ObservableInputTuple<T>]): Observable<T[number]>;

export function raceInit<T>(sources: ObservableInput<T>[]) {
return (subscriber: Subscriber<T>) => {
return (destination: Subscriber<T>) => {
let subscriptions: Subscription[] = [];

@@ -72,15 +71,18 @@

// stop before it subscribes to any more.
for (let i = 0; subscriptions && !subscriber.closed && i < sources.length; i++) {
for (let i = 0; subscriptions && !destination.closed && i < sources.length; i++) {
subscriptions.push(
from(sources[i] as ObservableInput<T>).subscribe(
createOperatorSubscriber(subscriber, (value) => {
if (subscriptions) {
// We're still racing, but we won! So unsubscribe
// all other subscriptions that we have, except this one.
for (let s = 0; s < subscriptions.length; s++) {
s !== i && subscriptions[s].unsubscribe();
operate({
destination,
next: (value) => {
if (subscriptions) {
// We're still racing, but we won! So unsubscribe
// all other subscriptions that we have, except this one.
for (let s = 0; s < subscriptions.length; s++) {
s !== i && subscriptions[s].unsubscribe();
}
subscriptions = null!;
}
subscriptions = null!;
}
subscriber.next(value);
destination.next(value);
},
})

@@ -87,0 +89,0 @@ )

@@ -6,3 +6,3 @@ import { Observable } from '../Observable';

import { EMPTY } from './empty';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';
import { operate } from '../Subscriber';
import { popResultSelector } from '../util/args';

@@ -60,3 +60,3 @@

return sources.length
? new Observable<unknown[]>((subscriber) => {
? new Observable<unknown[]>((destination) => {
// A collection of buffers of values from each source.

@@ -72,3 +72,3 @@ // Keyed by the same index with which the sources were passed in.

// When everything is done, release the arrays above.
subscriber.add(() => {
destination.add(() => {
buffers = completed = null!;

@@ -80,7 +80,7 @@ });

// access the related buffers and completion properties
for (let sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) {
for (let sourceIndex = 0; !destination.closed && sourceIndex < sources.length; sourceIndex++) {
from(sources[sourceIndex]).subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
buffers[sourceIndex].push(value);

@@ -93,3 +93,3 @@ // if every buffer has at least one value in it, then we

// Emit the array. If theres' a result selector, use that.
subscriber.next(resultSelector ? resultSelector(...result) : result);
destination.next(resultSelector ? resultSelector(...result) : result);
// If any one of the sources is both complete and has an empty buffer

@@ -99,7 +99,7 @@ // then we complete the result. This is because we cannot possibly have

if (buffers.some((buffer, i) => !buffer.length && completed[i])) {
subscriber.complete();
destination.complete();
}
}
},
() => {
complete: () => {
// This source completed. Mark it as complete so we can check it later

@@ -111,5 +111,5 @@ // if we have to.

// values from this to zip together with the other values.
!buffers[sourceIndex].length && subscriber.complete();
}
)
!buffers[sourceIndex].length && destination.complete();
},
})
);

@@ -116,0 +116,0 @@ }

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

import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { MonoTypeOperatorFunction, ObservableInput } from '../types';

@@ -6,3 +6,2 @@

import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';

@@ -56,3 +55,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let hasValue = false;

@@ -70,5 +69,5 @@ let lastValue: T | null = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}
isComplete && subscriber.complete();
isComplete && destination.complete();
};

@@ -78,9 +77,9 @@

durationSubscriber = null;
isComplete && subscriber.complete();
isComplete && destination.complete();
};
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
hasValue = true;

@@ -90,13 +89,17 @@ lastValue = value;

from(durationSelector(value)).subscribe(
(durationSubscriber = createOperatorSubscriber(subscriber, endDuration, cleanupDuration))
(durationSubscriber = operate({
destination,
next: endDuration,
complete: cleanupDuration,
}))
);
}
},
() => {
complete: () => {
isComplete = true;
(!hasValue || !durationSubscriber || durationSubscriber.closed) && subscriber.complete();
}
)
(!hasValue || !durationSubscriber || durationSubscriber.closed) && destination.complete();
},
})
);
});
}
import { OperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -47,3 +47,3 @@

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The current buffered values.

@@ -54,12 +54,12 @@ let currentBuffer: T[] = [];

from(closingNotifier).subscribe(
createOperatorSubscriber(
subscriber,
() => {
operate({
destination,
next: () => {
// Start a new buffer and emit the previous one.
const b = currentBuffer;
currentBuffer = [];
subscriber.next(b);
destination.next(b);
},
noop
)
complete: noop,
})
);

@@ -69,10 +69,10 @@

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => currentBuffer.push(value),
() => {
subscriber.next(currentBuffer);
subscriber.complete();
}
)
operate({
destination,
next: (value) => currentBuffer.push(value),
complete: () => {
destination.next(currentBuffer);
destination.complete();
},
})
);

@@ -79,0 +79,0 @@

import { OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { arrRemove } from '../util/arrRemove';

@@ -63,3 +63,3 @@

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let buffers: T[][] = [];

@@ -69,5 +69,5 @@ let count = 0;

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
let toEmit: T[][] | null = null;

@@ -102,23 +102,21 @@

arrRemove(buffers, buffer);
subscriber.next(buffer);
destination.next(buffer);
}
}
},
() => {
complete: () => {
// When the source completes, emit all of our
// active buffers.
for (const buffer of buffers) {
subscriber.next(buffer);
destination.next(buffer);
}
subscriber.complete();
destination.complete();
},
// Pass all errors through to consumer.
undefined,
() => {
finalize: () => {
// Clean up our memory when we finalize
buffers = null!;
}
)
},
})
);
});
}
import { Subscription } from '../Subscription';
import { OperatorFunction, SchedulerLike } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { arrRemove } from '../util/arrRemove';

@@ -81,3 +81,3 @@ import { asyncScheduler } from '../scheduler/async';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The active buffers, their related subscriptions, and removal functions.

@@ -99,3 +99,3 @@ let bufferRecords: { buffer: T[]; subs: Subscription }[] | null = [];

arrRemove(bufferRecords, record);
subscriber.next(buffer);
destination.next(buffer);
restartOnEmit && startBuffer();

@@ -112,3 +112,3 @@ };

const subs = new Subscription();
subscriber.add(subs);
destination.add(subs);
const buffer: T[] = [];

@@ -128,3 +128,3 @@ const record = {

// to wait the required time span before emitting.
executeSchedule(subscriber, scheduler, startBuffer, bufferCreationInterval, true);
executeSchedule(destination, scheduler, startBuffer, bufferCreationInterval, true);
} else {

@@ -136,5 +136,5 @@ restartOnEmit = true;

const bufferTimeSubscriber = createOperatorSubscriber(
subscriber,
(value: T) => {
const bufferTimeSubscriber = operate({
destination,
next: (value: T) => {
// Copy the records, so if we need to remove one we

@@ -153,17 +153,15 @@ // don't mutate the array. It's hard, but not impossible to

},
() => {
complete: () => {
// The source completed, emit all of the active
// buffers we have before we complete.
while (bufferRecords?.length) {
subscriber.next(bufferRecords.shift()!.buffer);
destination.next(bufferRecords.shift()!.buffer);
}
bufferTimeSubscriber?.unsubscribe();
subscriber.complete();
subscriber.unsubscribe();
destination.complete();
destination.unsubscribe();
},
// Pass all errors through to consumer.
undefined,
// Clean up
() => (bufferRecords = null)
);
finalize: () => (bufferRecords = null),
});

@@ -170,0 +168,0 @@ source.subscribe(bufferTimeSubscriber);

@@ -5,3 +5,3 @@ import { Subscription } from '../Subscription';

import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';

@@ -58,3 +58,3 @@ import { arrRemove } from '../util/arrRemove';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
const buffers: T[][] = [];

@@ -64,5 +64,5 @@

from(openings).subscribe(
createOperatorSubscriber(
subscriber,
(openValue) => {
operate({
destination,
next: (openValue) => {
const buffer: T[] = [];

@@ -76,3 +76,3 @@ buffers.push(buffer);

arrRemove(buffers, buffer);
subscriber.next(buffer);
destination.next(buffer);
closingSubscription.unsubscribe();

@@ -82,12 +82,12 @@ };

// The line below will add the subscription to the parent subscriber *and* the closing subscription.
closingSubscription.add(from(closingSelector(openValue)).subscribe(createOperatorSubscriber(subscriber, emitBuffer, noop)));
closingSubscription.add(from(closingSelector(openValue)).subscribe(operate({ destination, next: emitBuffer, complete: noop })));
},
noop
)
complete: noop,
})
);
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
// Value from our source. Add it to all pending buffers.

@@ -98,12 +98,12 @@ for (const buffer of buffers) {

},
() => {
complete: () => {
// Source complete. Emit all pending buffers.
while (buffers.length > 0) {
subscriber.next(buffers.shift()!);
destination.next(buffers.shift()!);
}
subscriber.complete();
}
)
destination.complete();
},
})
);
});
}

@@ -1,6 +0,5 @@

import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { ObservableInput, OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { from } from '../observable/from';

@@ -70,3 +69,9 @@

// Get a new closing notifier and subscribe to it.
from(closingSelector()).subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openBuffer, noop)));
from(closingSelector()).subscribe(
(closingSubscriber = operate({
destination: subscriber,
next: openBuffer,
complete: noop,
}))
);
};

@@ -79,19 +84,17 @@

source.subscribe(
createOperatorSubscriber(
subscriber,
operate({
destination: subscriber,
// Add every new value to the current buffer.
(value) => buffer?.push(value),
next: (value) => buffer?.push(value),
// When we complete, emit the buffer if we have one,
// then complete the result.
() => {
complete: () => {
buffer && subscriber.next(buffer);
subscriber.complete();
},
// Pass all errors through to consumer.
undefined,
// Release memory on finalization
() => (buffer = closingSubscriber = null!)
)
finalize: () => (buffer = closingSubscriber = null!),
})
);
});
}

@@ -5,3 +5,3 @@ import { Observable } from '../Observable';

import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -108,3 +108,3 @@ export function catchError<T, O extends ObservableInput<any>>(

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let innerSub: Subscription | null = null;

@@ -115,13 +115,16 @@ let syncUnsub = false;

innerSub = source.subscribe(
createOperatorSubscriber(subscriber, undefined, undefined, (err) => {
handledResult = from(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(subscriber);
} else {
// We don't have an innerSub yet, that means the error was synchronous
// because the subscribe call hasn't returned yet.
syncUnsub = true;
}
operate({
destination,
error: (err) => {
handledResult = from(selector(err, catchError(selector)(source)));
if (innerSub) {
innerSub.unsubscribe();
innerSub = null;
handledResult.subscribe(destination);
} else {
// We don't have an innerSub yet, that means the error was synchronous
// because the subscribe call hasn't returned yet.
syncUnsub = true;
}
},
})

@@ -138,5 +141,5 @@ );

innerSub = null;
handledResult!.subscribe(subscriber);
handledResult!.subscribe(destination);
}
});
}

@@ -1,6 +0,5 @@

import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { from } from '../observable/from';

@@ -68,3 +67,3 @@

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let hasValue = false;

@@ -86,3 +85,3 @@ let lastValue: T | null = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}

@@ -92,5 +91,5 @@ };

source.subscribe(
createOperatorSubscriber(
subscriber,
(value: T) => {
operate({
destination,
next: (value: T) => {
// Cancel any pending debounce duration. We don't

@@ -104,21 +103,19 @@ // need to null it out here yet tho, because we're just going

// and we're going to emit the value.
durationSubscriber = createOperatorSubscriber(subscriber, emit, noop);
durationSubscriber = operate({ destination, next: emit, complete: noop });
// Subscribe to the duration.
from(durationSelector(value)).subscribe(durationSubscriber);
},
() => {
complete: () => {
// Source completed.
// Emit any pending debounced values then complete
emit();
subscriber.complete();
destination.complete();
},
// Pass all errors through to consumer
undefined,
() => {
finalize: () => {
// Finalization.
lastValue = durationSubscriber = null;
}
)
},
})
);
});
}

@@ -5,3 +5,3 @@ import { asyncScheduler } from '../scheduler/async';

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

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

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let activeTask: Subscription | null = null;

@@ -82,3 +82,3 @@ let lastValue: T | null = null;

lastValue = null;
subscriber.next(value);
destination.next(value);
}

@@ -95,3 +95,3 @@ };

activeTask = this.schedule(undefined, targetTime - now);
subscriber.add(activeTask);
destination.add(activeTask);
return;

@@ -104,5 +104,5 @@ }

source.subscribe(
createOperatorSubscriber(
subscriber,
(value: T) => {
operate({
destination,
next: (value: T) => {
lastValue = value;

@@ -117,20 +117,18 @@ lastTime = scheduler.now();

// Set activeTask as intermediary Subscription to handle synchronous schedulers
subscriber.add(activeTask);
destination.add(activeTask);
}
},
() => {
complete: () => {
// Source completed.
// Emit any pending debounced values then complete
emit();
subscriber.complete();
destination.complete();
},
// Pass all errors through to consumer.
undefined,
() => {
finalize: () => {
// Finalization.
lastValue = activeTask = null;
}
)
},
})
);
});
}
import { OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -42,20 +42,20 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let hasValue = false;
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
hasValue = true;
subscriber.next(value);
destination.next(value);
},
() => {
complete: () => {
if (!hasValue) {
subscriber.next(defaultValue!);
destination.next(defaultValue!);
}
subscriber.complete();
}
)
destination.complete();
},
})
);
});
}
import { observeNotification } from '../Notification';
import { OperatorFunction, ObservableNotification, ValueFromNotification } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -56,5 +56,5 @@ /**

return (source) =>
new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber, (notification) => observeNotification(notification, subscriber)));
new Observable((destination) => {
source.subscribe(operate({ destination, next: (notification) => observeNotification(notification, destination) }));
});
}
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';

@@ -66,16 +66,19 @@ import { from } from '../observable/from';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
const distinctKeys = new Set();
source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
const key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
subscriber.next(value);
}
operate({
destination,
next: (value) => {
const key = keySelector ? keySelector(value) : value;
if (!distinctKeys.has(key)) {
distinctKeys.add(key);
destination.next(value);
}
},
})
);
flushes && from(flushes).subscribe(createOperatorSubscriber(subscriber, () => distinctKeys.clear(), noop));
flushes && from(flushes).subscribe(operate({ destination, next: () => distinctKeys.clear(), complete: noop }));
});
}
import { MonoTypeOperatorFunction } from '../types';
import { identity } from '../util/identity';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -149,3 +149,3 @@ export function distinctUntilChanged<T>(comparator?: (previous: T, current: T) => boolean): MonoTypeOperatorFunction<T>;

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The previous key, used to compare against keys selected

@@ -158,21 +158,24 @@ // from new arrivals to determine "distinctiveness".

source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
// We always call the key selector.
const currentKey = keySelector(value);
operate({
destination,
next: (value) => {
// We always call the key selector.
const currentKey = keySelector(value);
// If it's the first value, we always emit it.
// Otherwise, we compare this key to the previous key, and
// if the comparer returns false, we emit.
if (first || !comparator!(previousKey, currentKey)) {
// Update our state *before* we emit the value
// as emission can be the source of re-entrant code
// in functional libraries like this. We only really
// need to do this if it's the first value, or if the
// key we're tracking in previous needs to change.
first = false;
previousKey = currentKey;
// If it's the first value, we always emit it.
// Otherwise, we compare this key to the previous key, and
// if the comparer returns false, we emit.
if (first || !comparator!(previousKey, currentKey)) {
// Update our state *before* we emit the value
// as emission can be the source of re-entrant code
// in functional libraries like this. We only really
// need to do this if it's the first value, or if the
// key we're tracking in previous needs to change.
first = false;
previousKey = currentKey;
// Emit the value!
subscriber.next(value);
}
// Emit the value!
destination.next(value);
}
},
})

@@ -179,0 +182,0 @@ );

/** prettier */
import { Observable } from '../Observable';
import { OperatorFunction, ValueFromArray } from '../types';
import { operate } from '../Subscriber';
import { subscribeToArray } from '../observable/from';
import { OperatorFunction, ValueFromArray } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from '../operators/OperatorSubscriber';

@@ -56,6 +56,9 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
source.subscribe(
createOperatorSubscriber(subscriber, undefined, () => {
subscribeToArray(values as readonly ValueFromArray<A>[], subscriber);
operate({
destination,
complete: () => {
subscribeToArray(values as readonly ValueFromArray<A>[], destination);
},
})

@@ -62,0 +65,0 @@ );

import { Observable } from '../Observable';
import { Falsy, OperatorFunction } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -48,20 +48,20 @@ export function every<T>(predicate: BooleanConstructor): OperatorFunction<T, Exclude<T, Falsy> extends never ? false : boolean>;

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let index = 0;
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
if (!predicate.call(thisArg, value, index++, source)) {
subscriber.next(false);
subscriber.complete();
destination.next(false);
destination.complete();
}
},
() => {
subscriber.next(true);
subscriber.complete();
}
)
complete: () => {
destination.next(true);
destination.complete();
},
})
);
});
}

@@ -1,6 +0,5 @@

import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
import { from } from '../observable/from';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';

@@ -54,3 +53,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let index = 0;

@@ -60,9 +59,12 @@ let innerSub: Subscriber<T> | null = null;

source.subscribe(
createOperatorSubscriber(
subscriber,
(outerValue) => {
operate({
destination,
next: (outerValue) => {
if (!innerSub) {
innerSub = createOperatorSubscriber(subscriber, undefined, () => {
innerSub = null;
isComplete && subscriber.complete();
innerSub = operate({
destination,
complete: () => {
innerSub = null;
isComplete && destination.complete();
},
});

@@ -72,9 +74,9 @@ from(project(outerValue, index++)).subscribe(innerSub);

},
() => {
complete: () => {
isComplete = true;
!innerSub && subscriber.complete();
}
)
!innerSub && destination.complete();
},
})
);
});
}
import { OperatorFunction, MonoTypeOperatorFunction, TruthyTypesOf } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -63,3 +63,3 @@ /** @deprecated Use a closure instead of a `thisArg`. Signatures accepting a `thisArg` will be removed in v8. */

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// An index passed to our predicate function on each call.

@@ -74,5 +74,5 @@ let index = 0;

// to the consumer.
createOperatorSubscriber(subscriber, (value) => predicate.call(thisArg, value, index++) && subscriber.next(value))
operate({ destination, next: (value) => predicate.call(thisArg, value, index++) && destination.next(value) })
);
});
}
import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { OperatorFunction, TruthyTypesOf } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';

@@ -59,3 +58,3 @@ export function find<T>(predicate: BooleanConstructor): OperatorFunction<T, TruthyTypesOf<T>>;

source: Observable<T>,
subscriber: Subscriber<any>
destination: Subscriber<any>
) {

@@ -65,17 +64,17 @@ const findIndex = emit === 'index';

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
const i = index++;
if (predicate(value, i, source)) {
subscriber.next(findIndex ? i : value);
subscriber.complete();
destination.next(findIndex ? i : value);
destination.complete();
}
},
() => {
subscriber.next(findIndex ? -1 : undefined);
subscriber.complete();
}
)
complete: () => {
destination.next(findIndex ? -1 : undefined);
destination.complete();
},
})
);
}

@@ -5,3 +5,3 @@ import { Observable } from '../Observable';

import { ObservableInput, Observer, OperatorFunction, SubjectLike } from '../types';
import { createOperatorSubscriber, OperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -148,3 +148,3 @@ export interface BasicGroupByOptions<K, T> {

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let element: ((value: any) => any) | void;

@@ -163,3 +163,3 @@ if (!elementOrOptions || typeof elementOrOptions === 'function') {

groups.forEach(cb);
cb(subscriber);
cb(destination);
};

@@ -171,8 +171,2 @@

// The number of actively subscribed groups
let activeGroups = 0;
// Whether or not teardown was attempted on this subscription.
let teardownAttempted = false;
// Capturing a reference to this, because we need a handle to it

@@ -185,5 +179,5 @@ // in `createGroupedObservable` below. This is what we use to

// Consider: `source.pipe(groupBy(fn), take(2))`.
const groupBySourceSubscriber = new OperatorSubscriber(
subscriber,
(value: T) => {
const groupBySourceSubscriber = operate({
destination,
next: (value: T) => {
// Because we have to notify all groups of any errors that occur in here,

@@ -204,6 +198,6 @@ // we have to add our own try/catch to ensure that those errors are propagated.

const grouped = createGroupedObservable(key, group);
subscriber.next(grouped);
destination.next(grouped);
if (duration) {
const durationSubscriber = createOperatorSubscriber(
const durationSubscriber = operate({
// Providing the group here ensures that it is disposed of -- via `unsubscribe` --

@@ -214,4 +208,4 @@ // when the duration subscription is torn down. That is important, because then

// `ObjectUnsubscribedError` and know they can't possibly get any notifications.
group as any,
() => {
destination: group as any,
next: () => {
// Our duration notified! We can complete the group.

@@ -222,10 +216,4 @@ // The group will be removed from the map in the finalization phase.

},
// Completions are also sent to the group, but just the group.
undefined,
// Errors on the duration subscriber are sent to the group
// but only the group. They are not sent to the main subscription.
undefined,
// Finalization: Remove this group from our map.
() => groups.delete(key)
);
finalize: () => groups.delete(key),
});

@@ -243,6 +231,6 @@ // Start our duration notifier.

},
// Error from the source.
error: handleError,
// Source completes.
() => notify((consumer) => consumer.complete()),
// Error from the source.
handleError,
complete: () => notify((consumer) => consumer.complete()),
// Free up memory.

@@ -252,11 +240,4 @@ // When the source subscription is _finally_ torn down, release the subjects and keys

// don't have to.
() => groups.clear(),
() => {
teardownAttempted = true;
// We only kill our subscription to the source if we have
// no active groups. As stated above, consider this scenario:
// source$.pipe(groupBy(fn), take(2)).
return activeGroups === 0;
}
);
finalize: () => groups.clear(),
});

@@ -272,13 +253,3 @@ // Subscribe to the source

function createGroupedObservable(key: K, groupSubject: SubjectLike<any>) {
const result: any = new Observable<T>((groupSubscriber) => {
activeGroups++;
const innerSub = groupSubject.subscribe(groupSubscriber);
return () => {
innerSub.unsubscribe();
// We can kill the subscription to our source if we now have no more
// active groups subscribed, and a finalization was already attempted on
// the source.
--activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe();
};
});
const result: any = new Observable<T>((groupSubscriber) => groupSubject.subscribe(groupSubscriber));
result.key = key;

@@ -285,0 +256,0 @@ return result;

import { OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';
import { Subscriber } from '../Subscriber';

@@ -44,5 +43,5 @@ /**

return (source) =>
new Observable((subscriber) => {
source.subscribe(createOperatorSubscriber(subscriber as Subscriber<unknown>, noop));
new Observable((destination) => {
source.subscribe(operate({ destination, next: noop }));
});
}
import { OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -68,17 +68,17 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
source.subscribe(
createOperatorSubscriber(
subscriber,
() => {
subscriber.next(false);
subscriber.complete();
operate({
destination,
next: () => {
destination.next(false);
destination.complete();
},
() => {
subscriber.next(true);
subscriber.complete();
}
)
complete: () => {
destination.next(true);
destination.complete();
},
})
);
});
}
import { OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -42,3 +42,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The index of the value from the source. Used with projection.

@@ -49,6 +49,9 @@ let index = 0;

source.subscribe(
createOperatorSubscriber(subscriber, (value: T) => {
// Call the projection function with the appropriate this context,
// and send the resulting value to the consumer.
subscriber.next(project(value, index++));
operate({
destination,
next: (value: T) => {
// Call the projection function with the appropriate this context,
// and send the resulting value to the consumer.
destination.next(project(value, index++));
},
})

@@ -55,0 +58,0 @@ );

import { COMPLETE_NOTIFICATION, errorNotification, nextNotification } from '../NotificationFactories';
import { OperatorFunction, ObservableNotification } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -56,20 +56,20 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
subscriber.next(nextNotification(value));
operate({
destination,
next: (value) => {
destination.next(nextNotification(value));
},
() => {
subscriber.next(COMPLETE_NOTIFICATION);
subscriber.complete();
error: (error) => {
destination.next(errorNotification(error));
destination.complete();
},
(error) => {
subscriber.next(errorNotification(error));
subscriber.complete();
}
)
complete: () => {
destination.next(COMPLETE_NOTIFICATION);
destination.complete();
},
})
);
});
}
import { Observable } from '../Observable';
import { from } from '../observable/from';
import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { ObservableInput, SchedulerLike } from '../types';
import { executeSchedule } from '../util/executeSchedule';
import { createOperatorSubscriber } from './OperatorSubscriber';

@@ -12,3 +11,3 @@ /**

* @param source The original source observable
* @param subscriber The consumer subscriber
* @param destination The consumer subscriber
* @param project The projection function to get our inner sources

@@ -24,3 +23,3 @@ * @param concurrent The number of concurrent inner subscriptions

source: Observable<T>,
subscriber: Subscriber<R>,
destination: Subscriber<R>,
project: (value: T, index: number) => ObservableInput<R>,

@@ -50,3 +49,3 @@ concurrent: number,

if (isComplete && !buffer.length && !active) {
subscriber.complete();
destination.complete();
}

@@ -62,3 +61,3 @@ };

// back to the projection mechanism.
expand && subscriber.next(value as any);
expand && destination.next(value as any);

@@ -76,5 +75,5 @@ // Increment the number of active subscriptions so we can track it

from(project(value, index++)).subscribe(
createOperatorSubscriber(
subscriber,
(innerValue) => {
operate({
destination,
next: (innerValue) => {
// `mergeScan` has additional handling here. For example

@@ -90,6 +89,6 @@ // taking the inner value and updating state.

// Otherwise, emit the inner value.
subscriber.next(innerValue);
destination.next(innerValue);
}
},
() => {
complete: () => {
// Flag that we have completed, so we know to check the buffer

@@ -99,5 +98,3 @@ // during finalization.

},
// Errors are passed to the destination.
undefined,
() => {
finalize: () => {
// During finalization, if the inner completed (it wasn't errored or

@@ -126,3 +123,3 @@ // cancelled), then we want to try the next item in the buffer if

if (innerSubScheduler) {
executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));
executeSchedule(destination, innerSubScheduler, () => doInnerSub(bufferedValue));
} else {

@@ -135,7 +132,7 @@ doInnerSub(bufferedValue);

} catch (err) {
subscriber.error(err);
destination.error(err);
}
}
}
)
},
})
);

@@ -146,6 +143,10 @@ };

source.subscribe(
createOperatorSubscriber(subscriber, outerNext, () => {
// Outer completed, make a note of it, and check to see if we can complete everything.
isComplete = true;
checkComplete();
operate({
destination,
next: outerNext,
complete: () => {
// Outer completed, make a note of it, and check to see if we can complete everything.
isComplete = true;
checkComplete();
},
})

@@ -152,0 +153,0 @@ );

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

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -62,12 +62,12 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay),
() => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay),
(err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)
)
operate({
destination,
next: (value) => executeSchedule(destination, scheduler, () => destination.next(value), delay),
error: (err) => executeSchedule(destination, scheduler, () => destination.error(err), delay),
complete: () => executeSchedule(destination, scheduler, () => destination.complete(), delay),
})
);
});
}
import { OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -50,11 +50,14 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let prev: T;
let hasPrev = false;
source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
const p = prev;
prev = value;
hasPrev && subscriber.next([p, value]);
hasPrev = true;
operate({
destination,
next: (value) => {
const p = prev;
prev = value;
hasPrev && destination.next([p, value]);
hasPrev = true;
},
})

@@ -61,0 +64,0 @@ );

@@ -5,3 +5,3 @@ import { Subscription } from '../Subscription';

import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -132,3 +132,3 @@ import { timer } from '../observable/timer';

: (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let soFar = 0;

@@ -142,5 +142,8 @@ let sourceSub: Subscription | null;

const notifier = typeof delay === 'number' ? timer(delay) : from(delay(soFar));
const notifierSubscriber = createOperatorSubscriber(subscriber, () => {
notifierSubscriber.unsubscribe();
subscribeToSource();
const notifierSubscriber = operate({
destination,
next: () => {
notifierSubscriber.unsubscribe();
subscribeToSource();
},
});

@@ -156,12 +159,15 @@ notifier.subscribe(notifierSubscriber);

sourceSub = source.subscribe(
createOperatorSubscriber(subscriber, undefined, () => {
if (++soFar < count) {
if (sourceSub) {
resubscribe();
operate({
destination,
complete: () => {
if (++soFar < count) {
if (sourceSub) {
resubscribe();
} else {
syncUnsub = true;
}
} else {
syncUnsub = true;
destination.complete();
}
} else {
subscriber.complete();
}
},
})

@@ -168,0 +174,0 @@ );

@@ -7,3 +7,3 @@ import { Observable } from '../Observable';

import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -46,3 +46,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let innerSub: Subscription | null;

@@ -57,3 +57,3 @@ let syncResub = false;

*/
const checkComplete = () => isMainComplete && isNotifierComplete && (subscriber.complete(), true);
const checkComplete = () => isMainComplete && isNotifierComplete && (destination.complete(), true);
/**

@@ -70,5 +70,5 @@ * Gets the subject to send errors through. If it doesn't exist,

from(notifier(completions$)).subscribe(
createOperatorSubscriber(
subscriber,
() => {
operate({
destination,
next: () => {
if (innerSub) {

@@ -84,7 +84,7 @@ subscribeForRepeatWhen();

},
() => {
complete: () => {
isNotifierComplete = true;
checkComplete();
}
)
},
})
);

@@ -99,10 +99,13 @@ }

innerSub = source.subscribe(
createOperatorSubscriber(subscriber, undefined, () => {
isMainComplete = true;
// Check to see if we are complete, and complete if so.
// If we are not complete. Get the subject. This calls the `notifier` function.
// If that function fails, it will throw and `.next()` will not be reached on this
// line. The thrown error is caught by the _complete handler in this
// `OperatorSubscriber` and handled appropriately.
!checkComplete() && getCompletionSubject().next();
operate({
destination,
complete: () => {
isMainComplete = true;
// Check to see if we are complete, and complete if so.
// If we are not complete. Get the subject. This calls the `notifier` function.
// If that function fails, it will throw and `.next()` will not be reached on this
// line. The thrown error is caught by the _complete handler in this
// `OperatorSubscriber` and handled appropriately.
!checkComplete() && getCompletionSubject().next();
},
})

@@ -109,0 +112,0 @@ );

import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { Subscription } from '../Subscription';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { identity } from '../util/identity';

@@ -98,3 +98,3 @@ import { timer } from '../observable/timer';

: (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let soFar = 0;

@@ -105,5 +105,5 @@ let innerSub: Subscription | null;

innerSub = source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
// If we're resetting on success

@@ -113,7 +113,5 @@ if (resetOnSuccess) {

}
subscriber.next(value);
destination.next(value);
},
// Completions are passed through to consumer.
undefined,
(err) => {
error: (err) => {
if (soFar++ < count) {

@@ -136,5 +134,5 @@ // We are still under our retry count

const notifier = typeof delay === 'number' ? timer(delay) : from(delay(err, soFar));
const notifierSubscriber = createOperatorSubscriber(
subscriber,
() => {
const notifierSubscriber = operate({
destination,
next: () => {
// After we get the first notification, we

@@ -146,8 +144,8 @@ // unsubscribe from the notifier, because we don't want anymore

},
() => {
complete: () => {
// The notifier completed without emitting.
// The author is telling us they want to complete.
subscriber.complete();
}
);
destination.complete();
},
});
notifier.subscribe(notifierSubscriber);

@@ -161,6 +159,6 @@ } else {

// Just send along the error.
subscriber.error(err);
destination.error(err);
}
}
)
},
})
);

@@ -167,0 +165,0 @@ if (syncUnsub) {

@@ -7,3 +7,3 @@ import { Observable } from '../Observable';

import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -69,3 +69,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let innerSub: Subscription | null;

@@ -77,20 +77,25 @@ let syncResub = false;

innerSub = source.subscribe(
createOperatorSubscriber(subscriber, undefined, undefined, (err) => {
if (!errors$) {
errors$ = new Subject();
from(notifier(errors$)).subscribe(
createOperatorSubscriber(subscriber, () =>
// If we have an innerSub, this was an asynchronous call, kick off the retry.
// Otherwise, if we don't have an innerSub yet, that's because the inner subscription
// call hasn't even returned yet. We've arrived here synchronously.
// So we flag that we want to resub, such that we can ensure finalization
// happens before we resubscribe.
innerSub ? subscribeForRetryWhen() : (syncResub = true)
)
);
}
if (errors$) {
// We have set up the notifier without error.
errors$.next(err);
}
operate({
destination,
error: (err) => {
if (!errors$) {
errors$ = new Subject();
from(notifier(errors$)).subscribe(
operate({
destination,
next: () =>
// If we have an innerSub, this was an asynchronous call, kick off the retry.
// Otherwise, if we don't have an innerSub yet, that's because the inner subscription
// call hasn't even returned yet. We've arrived here synchronously.
// So we flag that we want to resub, such that we can ensure finalization
// happens before we resubscribe.
innerSub ? subscribeForRetryWhen() : (syncResub = true),
})
);
}
if (errors$) {
// We have set up the notifier without error.
errors$.next(err);
}
},
})

@@ -97,0 +102,0 @@ );

@@ -5,3 +5,3 @@ import { from } from '../observable/from';

import { noop } from '../util/noop';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -50,15 +50,18 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let hasValue = false;
let lastValue: T | null = null;
source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
hasValue = true;
lastValue = value;
operate({
destination,
next: (value) => {
hasValue = true;
lastValue = value;
},
})
);
from(notifier).subscribe(
createOperatorSubscriber(
subscriber,
() => {
operate({
destination,
next: () => {
if (hasValue) {

@@ -68,9 +71,9 @@ hasValue = false;

lastValue = null;
subscriber.next(value);
destination.next(value);
}
},
noop
)
complete: noop,
})
);
});
}
import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { Subscriber, operate } from '../Subscriber';

@@ -21,3 +20,3 @@ /**

source: Observable<V>,
subscriber: Subscriber<any>
destination: Subscriber<any>
) {

@@ -37,5 +36,5 @@ // Whether or not we have state yet. This will only be

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
// Always increment the index.

@@ -53,14 +52,14 @@ const i = index++;

// Maybe send it to the consumer.
emitOnNext && subscriber.next(state);
emitOnNext && destination.next(state);
},
// If an onComplete was given, call it, otherwise
// just pass through the complete notification to the consumer.
emitBeforeComplete
complete: emitBeforeComplete
? () => {
hasState && subscriber.next(state);
subscriber.complete();
hasState && destination.next(state);
destination.complete();
}
: undefined
)
: undefined,
})
);
}
import { OperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -68,3 +68,3 @@

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The state for the source observable

@@ -77,4 +77,4 @@ const aState = createState<T>();

const emit = (isEqual: boolean) => {
subscriber.next(isEqual);
subscriber.complete();
destination.next(isEqual);
destination.complete();
};

@@ -88,5 +88,5 @@

const createSubscriber = (selfState: SequenceState<T>, otherState: SequenceState<T>) => {
const sequenceEqualSubscriber = createOperatorSubscriber(
subscriber,
(a: T) => {
const sequenceEqualSubscriber = operate<T, boolean>({
destination,
next: (a) => {
const { buffer, complete } = otherState;

@@ -108,3 +108,3 @@ if (buffer.length === 0) {

},
() => {
complete: () => {
// Or observable completed

@@ -120,4 +120,4 @@ selfState.complete = true;

sequenceEqualSubscriber?.unsubscribe();
}
);
},
});

@@ -124,0 +124,0 @@ return sequenceEqualSubscriber;

@@ -7,3 +7,3 @@ import { Observable } from '../Observable';

import { NotFoundError } from '../util/NotFoundError';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -95,3 +95,3 @@ export function single<T>(predicate: BooleanConstructor): OperatorFunction<T, TruthyTypesOf<T>>;

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let hasValue = false;

@@ -102,8 +102,8 @@ let singleValue: T;

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
seenValue = true;
if (!predicate || predicate(value, index++, source)) {
hasValue && subscriber.error(new SequenceError('Too many matching values'));
hasValue && destination.error(new SequenceError('Too many matching values'));
hasValue = true;

@@ -113,13 +113,13 @@ singleValue = value;

},
() => {
complete: () => {
if (hasValue) {
subscriber.next(singleValue);
subscriber.complete();
destination.next(singleValue);
destination.complete();
} else {
subscriber.error(seenValue ? new NotFoundError('No matching values') : new EmptyError());
destination.error(seenValue ? new NotFoundError('No matching values') : new EmptyError());
}
}
)
},
})
);
});
}
import { MonoTypeOperatorFunction } from '../types';
import { identity } from '../util/identity';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -53,3 +53,3 @@ /**

: (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// A ring buffer to hold the values while we wait to see

@@ -63,28 +63,31 @@ // if we can emit it or it's part of the "skipped" last values.

source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
// Get the index of the value we have right now
// relative to all other values we've seen, then
// increment `seen`. This ensures we've moved to
// the next slot in our ring buffer.
const valueIndex = seen++;
if (valueIndex < skipCount) {
// If we haven't seen enough values to fill our buffer yet,
// Then we aren't to a number of seen values where we can
// emit anything, so let's just start by filling the ring buffer.
ring[valueIndex] = value;
} else {
// We are traversing over the ring array in such
// a way that when we get to the end, we loop back
// and go to the start.
const index = valueIndex % skipCount;
// Pull the oldest value out so we can emit it,
// and stuff the new value in it's place.
const oldValue = ring[index];
ring[index] = value;
// Emit the old value. It is important that this happens
// after we swap the value in the buffer, if it happens
// before we swap the value in the buffer, then a synchronous
// source can get the buffer out of whack.
subscriber.next(oldValue);
}
operate({
destination,
next: (value) => {
// Get the index of the value we have right now
// relative to all other values we've seen, then
// increment `seen`. This ensures we've moved to
// the next slot in our ring buffer.
const valueIndex = seen++;
if (valueIndex < skipCount) {
// If we haven't seen enough values to fill our buffer yet,
// Then we aren't to a number of seen values where we can
// emit anything, so let's just start by filling the ring buffer.
ring[valueIndex] = value;
} else {
// We are traversing over the ring array in such
// a way that when we get to the end, we loop back
// and go to the start.
const index = valueIndex % skipCount;
// Pull the oldest value out so we can emit it,
// and stuff the new value in it's place.
const oldValue = ring[index];
ring[index] = value;
// Emit the old value. It is important that this happens
// after we swap the value in the buffer, if it happens
// before we swap the value in the buffer, then a synchronous
// source can get the buffer out of whack.
destination.next(oldValue);
}
},
})

@@ -91,0 +94,0 @@ );

import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -54,18 +54,18 @@ import { noop } from '../util/noop';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let taking = false;
const skipSubscriber = createOperatorSubscriber(
subscriber,
() => {
const skipSubscriber = operate({
destination,
next: () => {
skipSubscriber?.unsubscribe();
taking = true;
},
noop
);
complete: noop,
});
from(notifier).subscribe(skipSubscriber);
source.subscribe(createOperatorSubscriber(subscriber, (value) => taking && subscriber.next(value)));
source.subscribe(operate({ destination, next: (value) => taking && destination.next(value) }));
});
}
import { Falsy, MonoTypeOperatorFunction, OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -54,9 +54,9 @@ export function skipWhile<T>(predicate: BooleanConstructor): OperatorFunction<T, Extract<T, Falsy> extends never ? never : T>;

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let taking = false;
let index = 0;
source.subscribe(
createOperatorSubscriber(subscriber, (value) => (taking || (taking = !predicate(value, index++))) && subscriber.next(value))
operate({ destination, next: (value) => (taking || (taking = !predicate(value, index++))) && destination.next(value) })
);
});
}

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

import { concat } from '../observable/concat';
import { OperatorFunction, SchedulerLike, ValueFromArray } from '../types';
import { popScheduler } from '../util/args';
import { Observable } from '../Observable';
import { subscribeToArray } from '../observable/from';
import { operate } from '../Subscriber';
import { OperatorFunction, ValueFromArray } from '../types';
// Devs are more likely to pass null or undefined than they are a scheduler
// without accompanying values. To make things easier for (naughty) devs who
// use the `strictNullChecks: false` TypeScript compiler option, these
// overloads with explicit null and undefined values are included.
export function startWith<T>(value: null): OperatorFunction<T, T | null>;
export function startWith<T>(value: undefined): OperatorFunction<T, T | undefined>;
/** @deprecated The `scheduler` parameter will be removed in v8. Use `scheduled` and `concatAll`. Details: https://rxjs.dev/deprecations/scheduler-argument */
export function startWith<T, A extends readonly unknown[] = T[]>(
...valuesAndScheduler: [...A, SchedulerLike]
): OperatorFunction<T, T | ValueFromArray<A>>;
export function startWith<T, A extends readonly unknown[] = T[]>(...values: A): OperatorFunction<T, T | ValueFromArray<A>>;

@@ -60,10 +50,6 @@

export function startWith<T, D>(...values: D[]): OperatorFunction<T, T | D> {
const scheduler = popScheduler(values);
return (source) =>
new Observable((subscriber) => {
// Here we can't pass `undefined` as a scheduler, because if we did, the
// code inside of `concat` would be confused by the `undefined`, and treat it
// like an invalid observable. So we have to split it two different ways.
(scheduler ? concat(values, source, scheduler) : concat(values, source)).subscribe(subscriber);
new Observable((destination) => {
subscribeToArray(values, operate({ destination, complete: () => source.subscribe(destination) }));
});
}

@@ -1,6 +0,5 @@

import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
import { from } from '../observable/from';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';

@@ -72,3 +71,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let innerSubscriber: Subscriber<ObservedValueOf<O>> | null = null;

@@ -81,8 +80,8 @@ let index = 0;

// This is called both when the source completes and when the inners complete.
const checkComplete = () => isComplete && !innerSubscriber && subscriber.complete();
const checkComplete = () => isComplete && !innerSubscriber && destination.complete();
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
// Cancel the previous inner subscription if there was one

@@ -93,18 +92,21 @@ innerSubscriber?.unsubscribe();

from(project(value, outerIndex)).subscribe(
(innerSubscriber = createOperatorSubscriber(subscriber, undefined, () => {
// The inner has completed. Null out the inner subscriber to
// free up memory and to signal that we have no inner subscription
// currently.
innerSubscriber = null!;
checkComplete();
(innerSubscriber = operate({
destination,
complete: () => {
// The inner has completed. Null out the inner subscriber to
// free up memory and to signal that we have no inner subscription
// currently.
innerSubscriber = null!;
checkComplete();
},
}))
);
},
() => {
complete: () => {
isComplete = true;
checkComplete();
}
)
},
})
);
});
}
import { ObservableInput, ObservedValueOf, OperatorFunction } from '../types';
import { switchMap } from './switchMap';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -30,3 +30,3 @@ // TODO: Generate a marble diagram for these docs.

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The state we will keep up to date to pass into our

@@ -44,6 +44,9 @@ // accumulator function at each new value from the source.

)(source).subscribe(
createOperatorSubscriber(subscriber, (innerValue) => {
// Update our state with the flattened value.
state = innerValue;
subscriber.next(innerValue);
operate({
destination,
next: (innerValue) => {
// Update our state with the flattened value.
state = innerValue;
destination.next(innerValue);
},
})

@@ -50,0 +53,0 @@ );

import { MonoTypeOperatorFunction } from '../types';
import { EMPTY } from '../observable/empty';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -53,12 +53,15 @@ /**

: (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let seen = 0;
const operatorSubscriber = createOperatorSubscriber<T>(subscriber, (value) => {
if (++seen < count) {
subscriber.next(value);
} else {
operatorSubscriber.unsubscribe();
subscriber.next(value);
subscriber.complete();
}
const operatorSubscriber = operate<T, T>({
destination,
next: (value) => {
if (++seen < count) {
destination.next(value);
} else {
operatorSubscriber.unsubscribe();
destination.next(value);
destination.complete();
}
},
});

@@ -65,0 +68,0 @@ source.subscribe(operatorSubscriber);

import { EMPTY } from '../observable/empty';
import { MonoTypeOperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -49,3 +49,3 @@ /**

: (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// This is a ring buffer that will hold our values

@@ -56,8 +56,8 @@ let ring = new Array<T>(count);

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
ring[counter++ % count] = value;
},
() => {
complete: () => {
// We need to loop through our ring buffer.

@@ -74,16 +74,14 @@ // If we haven't filled the buffer yet, we can start at zero.

// the remaining values, if necessary.
subscriber.next(ring[(start + n) % count]);
destination.next(ring[(start + n) % count]);
}
// All done. This will also trigger clean up.
subscriber.complete();
destination.complete();
},
// Errors are passed through to the consumer
undefined,
() => {
finalize: () => {
// During finalization release the values in our buffer.
ring = null!;
}
)
},
})
);
});
}
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -47,6 +47,6 @@ import { noop } from '../util/noop';

return (source) =>
new Observable((subscriber) => {
from(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
!subscriber.closed && source.subscribe(subscriber);
new Observable((destination) => {
from(notifier).subscribe(operate({ destination, next: () => destination.complete(), complete: noop }));
!destination.closed && source.subscribe(destination);
});
}
import { OperatorFunction, MonoTypeOperatorFunction, TruthyTypesOf } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -57,14 +57,17 @@ export function takeWhile<T>(predicate: BooleanConstructor, inclusive: true): MonoTypeOperatorFunction<T>;

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let index = 0;
const operatorSubscriber = createOperatorSubscriber<T>(subscriber, (value) => {
if (predicate(value, index++)) {
subscriber.next(value);
} else {
operatorSubscriber.unsubscribe();
if (inclusive) {
subscriber.next(value);
const operatorSubscriber = operate({
destination,
next: (value: T) => {
if (predicate(value, index++)) {
destination.next(value);
} else {
operatorSubscriber.unsubscribe();
if (inclusive) {
destination.next(value);
}
destination.complete();
}
subscriber.complete();
}
},
});

@@ -71,0 +74,0 @@

import { MonoTypeOperatorFunction, Observer } from '../types';
import { isFunction } from '../util/isFunction';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { identity } from '../util/identity';

@@ -164,23 +164,23 @@

? (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
tapObserver.subscribe?.();
let isUnsub = true;
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
tapObserver.next?.(value);
subscriber.next(value);
destination.next(value);
},
() => {
error: (err) => {
isUnsub = false;
tapObserver.complete?.();
subscriber.complete();
tapObserver.error?.(err);
destination.error(err);
},
(err) => {
complete: () => {
isUnsub = false;
tapObserver.error?.(err);
subscriber.error(err);
tapObserver.complete?.();
destination.complete();
},
() => {
finalize: () => {
if (isUnsub) {

@@ -190,4 +190,4 @@ tapObserver.unsubscribe?.();

tapObserver.finalize?.();
}
)
},
})
);

@@ -194,0 +194,0 @@ })

@@ -5,3 +5,3 @@ import { Subscription } from '../Subscription';

import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -87,3 +87,3 @@

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
const { leading = true, trailing = false } = config ?? {};

@@ -100,3 +100,3 @@ let hasValue = false;

send();
isComplete && subscriber.complete();
isComplete && destination.complete();
}

@@ -107,7 +107,7 @@ };

throttled = null;
isComplete && subscriber.complete();
isComplete && destination.complete();
};
const startThrottle = (value: T) =>
(throttled = from(durationSelector(value)).subscribe(createOperatorSubscriber(subscriber, endThrottling, cleanupThrottling)));
(throttled = from(durationSelector(value)).subscribe(operate({ destination, next: endThrottling, complete: cleanupThrottling })));

@@ -123,3 +123,3 @@ const send = () => {

// Emit the value.
subscriber.next(value);
destination.next(value);
!isComplete && startThrottle(value);

@@ -130,4 +130,4 @@ }

source.subscribe(
createOperatorSubscriber(
subscriber,
operate({
destination,
// Regarding the presence of throttled.closed in the following

@@ -138,3 +138,3 @@ // conditions, if a synchronous duration selector is specified - weird,

// too.
(value) => {
next: (value) => {
hasValue = true;

@@ -144,9 +144,9 @@ sendValue = value;

},
() => {
complete: () => {
isComplete = true;
!(trailing && hasValue && throttled && !throttled.closed) && subscriber.complete();
}
)
!(trailing && hasValue && throttled && !throttled.closed) && destination.complete();
},
})
);
});
}
import { EmptyError } from '../util/EmptyError';
import { MonoTypeOperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -44,13 +44,13 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let hasValue = false;
source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
hasValue = true;
subscriber.next(value);
destination.next(value);
},
() => (hasValue ? subscriber.complete() : subscriber.error(errorFactory()))
)
complete: () => (hasValue ? destination.complete() : destination.error(errorFactory())),
})
);

@@ -57,0 +57,0 @@ });

import { asyncScheduler } from '../scheduler/async';
import { SchedulerLike, OperatorFunction } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -47,10 +47,13 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let last = scheduler.now();
source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
const now = scheduler.now();
const interval = now - last;
last = now;
subscriber.next(new TimeInterval(value, interval));
operate({
destination,
next: (value) => {
const now = scheduler.now();
const interval = now - last;
last = now;
destination.next(new TimeInterval(value, interval));
},
})

@@ -57,0 +60,0 @@ );

@@ -7,4 +7,3 @@ import { asyncScheduler } from '../scheduler/async';

import { from } from '../observable/from';
import { createErrorClass } from '../util/createErrorClass';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { executeSchedule } from '../util/executeSchedule';

@@ -55,7 +54,14 @@

/**
* An error emitted when a timeout occurs.
* An error thrown by the {@link timeout} operator.
*
* Provided so users can use as a type and do quality comparisons.
* We recommend you do not subclass this or create instances of this class directly.
* If you have need of a error representing a timeout, you should
* create your own error class and use that.
*
* @see {@link timeout}
*/
export interface TimeoutError<T = unknown, M = unknown> extends Error {
export class TimeoutError<T, M> extends Error {
/**
* The information provided to the error by the timeout
* @param info The information provided to the error by the timeout
* operation that created the error. Will be `null` if

@@ -65,35 +71,12 @@ * used directly in non-RxJS code with an empty constructor.

* you should create your own errors)
*/
info: TimeoutInfo<T, M> | null;
}
export interface TimeoutErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new <T = unknown, M = unknown>(info?: TimeoutInfo<T, M>): TimeoutError<T, M>;
constructor(public info: TimeoutInfo<T, M> | null = null) {
super('Timeout has occurred');
this.name = 'TimeoutError';
}
}
/**
* An error thrown by the {@link timeout} operator.
*
* Provided so users can use as a type and do quality comparisons.
* We recommend you do not subclass this or create instances of this class directly.
* If you have need of a error representing a timeout, you should
* create your own error class and use that.
*
* @see {@link timeout}
*/
export const TimeoutError: TimeoutErrorCtor = createErrorClass(
(_super) =>
function TimeoutErrorImpl(this: any, info: TimeoutInfo<any> | null = null) {
_super(this);
this.message = 'Timeout has occurred';
this.name = 'TimeoutError';
this.info = info;
}
);
/**
* If `with` is provided, this will return an observable that will switch to a different observable if the source

@@ -326,3 +309,3 @@ * does not push values within the specified time parameters.

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// This subscription encapsulates our subscription to the

@@ -345,3 +328,3 @@ // source for this operator. We're capturing it separately,

timerSubscription = executeSchedule(
subscriber,
destination,
scheduler,

@@ -357,5 +340,5 @@ () => {

})
).subscribe(subscriber);
).subscribe(destination);
} catch (err) {
subscriber.error(err);
destination.error(err);
}

@@ -368,5 +351,5 @@ },

originalSourceSubscription = source.subscribe(
createOperatorSubscriber(
subscriber,
(value: T) => {
operate({
destination,
next: (value: T) => {
// clear the timer so we can emit and start another one.

@@ -376,9 +359,7 @@ timerSubscription?.unsubscribe();

// Emit
subscriber.next((lastValue = value));
destination.next((lastValue = value));
// null | undefined are both < 0. Thanks, JavaScript.
each! > 0 && startTimer(each!);
},
undefined,
undefined,
() => {
finalize: () => {
if (!timerSubscription?.closed) {

@@ -390,4 +371,4 @@ timerSubscription?.unsubscribe();

lastValue = null;
}
)
},
})
);

@@ -394,0 +375,0 @@

import { Observable } from '../Observable';
import { OperatorFunction, ObservableInput } from '../types';
import { Subject } from '../Subject';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';

@@ -54,10 +54,10 @@ import { from } from '../observable/from';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let windowSubject: Subject<T> = new Subject<T>();
subscriber.next(windowSubject.asObservable());
destination.next(windowSubject.asObservable());
const errorHandler = (err: any) => {
windowSubject.error(err);
subscriber.error(err);
destination.error(err);
};

@@ -67,11 +67,11 @@

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => windowSubject?.next(value),
() => {
operate({
destination,
next: (value) => windowSubject?.next(value),
complete: () => {
windowSubject.complete();
subscriber.complete();
destination.complete();
},
errorHandler
)
error: errorHandler,
})
);

@@ -81,11 +81,11 @@

from(windowBoundaries).subscribe(
createOperatorSubscriber(
subscriber,
() => {
operate({
destination,
next: () => {
windowSubject.complete();
subscriber.next((windowSubject = new Subject()));
destination.next((windowSubject = new Subject()));
},
noop,
errorHandler
)
complete: noop,
error: errorHandler,
})
);

@@ -92,0 +92,0 @@

import { Observable } from '../Observable';
import { Subject } from '../Subject';
import { OperatorFunction } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';

@@ -71,3 +71,3 @@ /**

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let windows = [new Subject<T>()];

@@ -78,8 +78,8 @@ let starts: number[] = [];

// Open the first window.
subscriber.next(windows[0].asObservable());
destination.next(windows[0].asObservable());
source.subscribe(
createOperatorSubscriber(
subscriber,
(value: T) => {
operate({
destination,
next: (value: T) => {
// Emit the value through all current windows.

@@ -109,24 +109,24 @@ // We don't need to create a new window yet, we

windows.push(window);
subscriber.next(window.asObservable());
destination.next(window.asObservable());
}
},
() => {
error: (err) => {
while (windows.length > 0) {
windows.shift()!.complete();
windows.shift()!.error(err);
}
subscriber.complete();
destination.error(err);
},
(err) => {
complete: () => {
while (windows.length > 0) {
windows.shift()!.error(err);
windows.shift()!.complete();
}
subscriber.error(err);
destination.complete();
},
() => {
finalize: () => {
starts = null!;
windows = null!;
}
)
},
})
);
});
}

@@ -6,3 +6,3 @@ import { Subject } from '../Subject';

import { Observer, OperatorFunction, SchedulerLike } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { arrRemove } from '../util/arrRemove';

@@ -112,3 +112,3 @@ import { popScheduler } from '../util/args';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
// The active windows, their related subscriptions, and removal functions.

@@ -135,3 +135,3 @@ let windowRecords: WindowRecord<T>[] | null = [];

const subs = new Subscription();
subscriber.add(subs);
destination.add(subs);
const window = new Subject<T>();

@@ -144,3 +144,3 @@ const record = {

windowRecords.push(record);
subscriber.next(window.asObservable());
destination.next(window.asObservable());
executeSchedule(subs, scheduler, () => closeWindow(record), windowTimeSpan);

@@ -154,3 +154,3 @@ }

// to wait the required time span before completing.
executeSchedule(subscriber, scheduler, startWindow, windowCreationInterval, true);
executeSchedule(destination, scheduler, startWindow, windowCreationInterval, true);
} else {

@@ -176,10 +176,10 @@ restartOnClose = true;

loop(({ window }) => cb(window));
cb(subscriber);
subscriber.unsubscribe();
cb(destination);
destination.unsubscribe();
};
source.subscribe(
createOperatorSubscriber(
subscriber,
(value: T) => {
operate({
destination,
next: (value: T) => {
// Notify all windows of the value.

@@ -192,7 +192,7 @@ loop((record) => {

},
// Notify the windows and the downstream subscriber of the error and clean up.
error: (err) => terminate((consumer) => consumer.error(err)),
// Complete the windows and the downstream subscriber and clean up.
() => terminate((consumer) => consumer.complete()),
// Notify the windows and the downstream subscriber of the error and clean up.
(err) => terminate((consumer) => consumer.error(err))
)
complete: () => terminate((consumer) => consumer.complete()),
})
);

@@ -199,0 +199,0 @@

@@ -6,3 +6,3 @@ import { Observable } from '../Observable';

import { from } from '../observable/from';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { noop } from '../util/noop';

@@ -61,3 +61,3 @@ import { arrRemove } from '../util/arrRemove';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
const windows: Subject<T>[] = [];

@@ -69,9 +69,9 @@

}
subscriber.error(err);
destination.error(err);
};
from(openings).subscribe(
createOperatorSubscriber(
subscriber,
(openValue) => {
operate({
destination,
next: (openValue) => {
const window = new Subject<T>();

@@ -97,8 +97,17 @@ windows.push(window);

// late. We should probably change that: (https://github.com/ReactiveX/rxjs/issues/7200)
subscriber.next(window);
destination.next(window);
closingSubscription.add(closingNotifier.subscribe(createOperatorSubscriber(subscriber, closeWindow, noop, handleError)));
closingSubscription.add(
closingNotifier.subscribe(
operate({
destination,
next: closeWindow,
error: handleError,
complete: noop,
})
)
);
},
noop
)
complete: noop,
})
);

@@ -108,5 +117,5 @@

source.subscribe(
createOperatorSubscriber(
subscriber,
(value: T) => {
operate({
destination,
next: (value: T) => {
// Copy the windows array before we emit to

@@ -119,3 +128,4 @@ // make sure we don't have issues with reentrant code.

},
() => {
error: handleError,
complete: () => {
// Complete all of our windows before we complete.

@@ -125,6 +135,5 @@ while (0 < windows.length) {

}
subscriber.complete();
destination.complete();
},
handleError,
() => {
finalize: () => {
// Add this finalization so that all window subjects are

@@ -138,6 +147,6 @@ // disposed of. This way, if a user tries to subscribe

}
}
)
},
})
);
});
}

@@ -1,6 +0,5 @@

import { Subscriber } from '../Subscriber';
import { Subscriber, operate } from '../Subscriber';
import { Observable } from '../Observable';
import { Subject } from '../Subject';
import { ObservableInput, OperatorFunction } from '../types';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { from } from '../observable/from';

@@ -58,3 +57,3 @@ import { noop } from '../util/noop';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
let window: Subject<T> | null;

@@ -69,3 +68,3 @@ let closingSubscriber: Subscriber<any> | undefined;

window!.error(err);
subscriber.error(err);
destination.error(err);
};

@@ -89,3 +88,3 @@

window = new Subject<T>();
subscriber.next(window.asObservable());
destination.next(window.asObservable());

@@ -105,3 +104,10 @@ // Get our closing notifier.

// and open a new one.
closingNotifier.subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openWindow, noop, handleError)));
closingNotifier.subscribe(
(closingSubscriber = operate({
destination,
next: openWindow,
error: handleError,
complete: noop,
}))
);
};

@@ -114,12 +120,12 @@

source.subscribe(
createOperatorSubscriber(
subscriber,
(value) => window!.next(value),
() => {
operate({
destination,
next: (value) => window!.next(value),
error: handleError,
complete: () => {
// The source completed, close the window and complete.
window!.complete();
subscriber.complete();
destination.complete();
},
handleError,
() => {
finalize: () => {
// Be sure to clean up our closing subscription

@@ -129,6 +135,6 @@ // when this tears down.

window = null!;
}
)
},
})
);
});
}
import { OperatorFunction, ObservableInputTuple } from '../types';
import { Observable } from '../Observable';
import { createOperatorSubscriber } from './OperatorSubscriber';
import { operate } from '../Subscriber';
import { from } from '../observable/from';

@@ -63,3 +63,3 @@ import { identity } from '../util/identity';

return (source) =>
new Observable((subscriber) => {
new Observable((destination) => {
const len = inputs.length;

@@ -81,5 +81,5 @@ const otherValues = new Array(len);

from(inputs[i]).subscribe(
createOperatorSubscriber(
subscriber,
(value) => {
operate({
destination,
next: (value) => {
otherValues[i] = value;

@@ -98,4 +98,4 @@ if (!ready && !hasValue[i]) {

// no bearing on the completion of our result.
noop
)
complete: noop,
})
);

@@ -106,8 +106,11 @@ }

source.subscribe(
createOperatorSubscriber(subscriber, (value) => {
if (ready) {
// We have at least one value from the other sources. Go ahead and emit.
const values = [value, ...otherValues];
subscriber.next(project ? project(...values) : values);
}
operate({
destination,
next: (value) => {
if (ready) {
// We have at least one value from the other sources. Go ahead and emit.
const values = [value, ...otherValues];
destination.next(project ? project(...values) : values);
}
},
})

@@ -114,0 +117,0 @@ );

@@ -9,2 +9,33 @@ import { isFunction } from './util/isFunction';

export interface SubscriberOverrides<T> {
/**
* If provided, this function will be called whenever the {@link Subscriber}'s
* `next` method is called, with the value that was passed to that call. If
* an error is thrown within this function, it will be handled and passed to
* the destination's `error` method.
* @param value The value that is being observed from the source.
*/
next?: (value: T) => void;
/**
* If provided, this function will be called whenever the {@link Subscriber}'s
* `error` method is called, with the error that was passed to that call. If
* an error is thrown within this function, it will be handled and passed to
* the destination's `error` method.
* @param err An error that has been thrown by the source observable.
*/
error?: (err: any) => void;
/**
* If provided, this function will be called whenever the {@link Subscriber}'s
* `complete` method is called. If an error is thrown within this function, it
* will be handled and passed to the destination's `error` method.
*/
complete?: () => void;
/**
* If provided, this function will be called after all teardown has occurred
* for this {@link Subscriber}. This is generally used for cleanup purposes
* during operator development.
*/
finalize?: () => void;
}
/**

@@ -24,7 +55,26 @@ * Implements the {@link Observer} interface and extends the

/** @internal */
protected readonly _nextOverride: ((value: T) => void) | null = null;
/** @internal */
protected readonly _errorOverride: ((err: any) => void) | null = null;
/** @internal */
protected readonly _completeOverride: (() => void) | null = null;
/** @internal */
protected readonly _onFinalize: (() => void) | null = null;
/**
* @deprecated Do not create instances of `Subscriber` directly. Use {@link operate} instead.
*/
constructor(destination?: Subscriber<T> | Partial<Observer<T>> | ((value: T) => void) | null);
/**
* @internal
*/
constructor(destination: Subscriber<any> | Partial<Observer<any>> | ((value: any) => void) | null, overrides: SubscriberOverrides<T>);
/**
* Creates an instance of an RxJS Subscriber. This is the workhorse of the library.
*
* If another instance of Subscriber is passed in, it will automatically wire up unsubscription
* between this instnace and the passed in instance.
* between this instance and the passed in instance.
*

@@ -36,8 +86,31 @@ * If a partial or full observer is passed in, it will be wrapped and appropriate safeguards will be applied.

* @param destination A subscriber, partial observer, or function that receives the next value.
* @deprecated Do not create instances of `Subscriber` directly. Use {@link operate} instead.
*/
constructor(destination?: Subscriber<T> | Partial<Observer<T>> | ((value: T) => void) | null) {
constructor(destination?: Subscriber<T> | Partial<Observer<T>> | ((value: T) => void) | null, overrides?: SubscriberOverrides<T>) {
super();
// The only way we know that error reporting safety has been applied is if we own it.
this.destination = destination instanceof Subscriber ? destination : createSafeObserver(destination);
this._nextOverride = overrides?.next ?? null;
this._errorOverride = overrides?.error ?? null;
this._completeOverride = overrides?.complete ?? null;
this._onFinalize = overrides?.finalize ?? null;
// It's important - for performance reasons - that all of this class's
// members are initialized and that they are always initialized in the same
// order. This will ensure that all Subscriber instances have the
// same hidden class in V8. This, in turn, will help keep the number of
// hidden classes involved in property accesses within the base class as
// low as possible. If the number of hidden classes involved exceeds four,
// the property accesses will become megamorphic and performance penalties
// will be incurred - i.e. inline caches won't be used.
//
// The reasons for ensuring all instances have the same hidden class are
// further discussed in this blog post from Benedikt Meurer:
// https://benediktmeurer.de/2018/03/23/impact-of-polymorphism-on-component-based-frameworks-like-react/
this._next = this._nextOverride ? overrideNext : this._next;
this._error = this._errorOverride ? overrideError : this._error;
this._complete = this._completeOverride ? overrideComplete : this._complete;
// Automatically chain subscriptions together here.

@@ -97,3 +170,3 @@ // if destination appears to be one of our subscriptions, we'll chain it.

super.unsubscribe();
this.destination = null!;
this._onFinalize?.();
}

@@ -123,2 +196,30 @@ }

function overrideNext<T>(this: Subscriber<T>, value: T): void {
try {
this._nextOverride!(value);
} catch (error) {
this.destination.error(error);
}
}
function overrideError(this: Subscriber<unknown>, err: any): void {
try {
this._errorOverride!(err);
} catch (error) {
this.destination.error(error);
} finally {
this.unsubscribe();
}
}
function overrideComplete(this: Subscriber<unknown>): void {
try {
this._completeOverride!();
} catch (error) {
this.destination.error(error);
} finally {
this.unsubscribe();
}
}
class ConsumerObserver<T> implements Observer<T> {

@@ -180,1 +281,34 @@ constructor(private partialObserver: Partial<Observer<T>>) {}

}
export interface OperateConfig<In, Out> extends SubscriberOverrides<In> {
/**
* The destination subscriber to forward notifications to. This is also the
* subscriber that will receive unhandled errors if your `next`, `error`, or `complete`
* overrides throw.
*/
destination: Subscriber<Out>;
}
/**
* Creates a new {@link Subscriber} instance that passes notifications on to the
* supplied `destination`. The overrides provided in the `config` argument for
* `next`, `error`, and `complete` will be called in such a way that any
* errors are caught and forwarded to the destination's `error` handler. The returned
* `Subscriber` will be "chained" to the `destination` such that when `unsubscribe` is
* called on the `destination`, the returned `Subscriber` will also be unsubscribed.
*
* Advanced: This ensures that subscriptions are properly wired up prior to starting the
* subcription logic. This prevents "synchronous firehose" scenarios where an
* inner observable from a flattening operation cannot be stopped by a downstream
* terminal operator like `take`.
*
* This is a utility designed to be used to create new operators for observables.
*
* For examples, please see our code base.
*
* @param config The configuration for creating a new subscriber for an operator.
* @returns A new subscriber that is chained to the destination.
*/
export function operate<In, Out>({ destination, ...subscriberOverrides }: OperateConfig<In, Out>) {
return new Subscriber(destination, subscriberOverrides);
}

@@ -1,13 +0,1 @@

import { createErrorClass } from './createErrorClass';
export interface ArgumentOutOfRangeError extends Error {}
export interface ArgumentOutOfRangeErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (): ArgumentOutOfRangeError;
}
/**

@@ -21,9 +9,11 @@ * An error thrown when an element was queried at a certain index of an

*/
export const ArgumentOutOfRangeError: ArgumentOutOfRangeErrorCtor = createErrorClass(
(_super) =>
function ArgumentOutOfRangeErrorImpl(this: any) {
_super(this);
this.name = 'ArgumentOutOfRangeError';
this.message = 'argument out of range';
}
);
export class ArgumentOutOfRangeError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor() {
super('argument out of range');
this.name = 'ArgumentOutOfRangeError';
}
}

@@ -1,13 +0,1 @@

import { createErrorClass } from './createErrorClass';
export interface EmptyError extends Error {}
export interface EmptyErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (): EmptyError;
}
/**

@@ -23,9 +11,11 @@ * An error thrown when an Observable or a sequence was queried but has no

*/
export const EmptyError: EmptyErrorCtor = createErrorClass(
(_super) =>
function EmptyErrorImpl(this: any) {
_super(this);
this.name = 'EmptyError';
this.message = 'no elements in sequence';
}
);
export class EmptyError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor() {
super('no elements in sequence');
this.name = 'EmptyError';
}
}

@@ -1,13 +0,1 @@

import { createErrorClass } from './createErrorClass';
export interface NotFoundError extends Error {}
export interface NotFoundErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (message: string): NotFoundError;
}
/**

@@ -19,9 +7,11 @@ * An error thrown when a value or values are missing from an

*/
export const NotFoundError: NotFoundErrorCtor = createErrorClass(
(_super) =>
function NotFoundErrorImpl(this: any, message: string) {
_super(this);
this.name = 'NotFoundError';
this.message = message;
}
);
export class NotFoundError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor(message: string) {
super(message);
this.name = 'NotFoundError';
}
}

@@ -76,3 +76,3 @@ import { identity } from './identity';

* It returns a function that takes one argument, passes it to the first UnaryFunction, and then
* passes the result to the next one, passes that result to the next one, and so on.
* passes the result to the next one, passes that result to the next one, and so on.
*/

@@ -84,3 +84,3 @@ export function pipe(...fns: Array<UnaryFunction<any, any>>): UnaryFunction<any, any> {

/** @internal */
export function pipeFromArray<T, R>(fns: Array<UnaryFunction<T, R>>): UnaryFunction<T, R> {
export function pipeFromArray(fns: UnaryFunction<unknown, unknown>[]): UnaryFunction<unknown, unknown> {
if (fns.length === 0) {

@@ -94,5 +94,5 @@ return identity as UnaryFunction<any, any>;

return function piped(input: T): R {
return fns.reduce((prev: any, fn: UnaryFunction<T, R>) => fn(prev), input as any);
return function piped(input) {
return fns.reduce((prev, fn) => fn(prev), input);
};
}

@@ -1,13 +0,1 @@

import { createErrorClass } from './createErrorClass';
export interface SequenceError extends Error {}
export interface SequenceErrorCtor {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
new (message: string): SequenceError;
}
/**

@@ -19,9 +7,11 @@ * An error thrown when something is wrong with the sequence of

*/
export const SequenceError: SequenceErrorCtor = createErrorClass(
(_super) =>
function SequenceErrorImpl(this: any, message: string) {
_super(this);
this.name = 'SequenceError';
this.message = message;
}
);
export class SequenceError extends Error {
/**
* @deprecated Internal implementation detail. Do not construct error instances.
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
*/
constructor(message: string) {
super(message);
this.name = 'SequenceError';
}
}

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

import { createErrorClass } from './createErrorClass';
export interface UnsubscriptionError extends Error {
readonly errors: any[];
}
export interface UnsubscriptionErrorCtor {
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
export class UnsubscriptionError extends Error {
/**

@@ -12,20 +10,11 @@ * @deprecated Internal implementation detail. Do not construct error instances.

*/
new (errors: any[]): UnsubscriptionError;
}
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
export const UnsubscriptionError: UnsubscriptionErrorCtor = createErrorClass(
(_super) =>
function UnsubscriptionErrorImpl(this: any, errors: (Error | string)[]) {
_super(this);
this.message = errors
constructor(public errors: any[]) {
super(
errors
? `${errors.length} errors occurred during unsubscription:
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
: '';
this.name = 'UnsubscriptionError';
this.errors = errors;
}
);
: ''
);
this.name = 'UnsubscriptionError';
}
}

@@ -8,4 +8,3 @@ {

"outDir": "../dist/cjs"
},
"exclude": ["./internal/umd.ts"]
}
}

@@ -5,6 +5,5 @@ {

"module": "esnext",
"importHelpers": true,
"target": "es2015",
"target": "ES2022",
"outDir": "../dist/esm"
}
}

@@ -6,3 +6,3 @@ {

"module": "es2015",
"target": "esnext",
"target": "ES2022",
"removeComments": false,

@@ -13,4 +13,3 @@ "declaration": true,

"emitDeclarationOnly": true
},
"exclude": ["./internal/umd.ts"]
}
}

@@ -5,5 +5,4 @@ {

"main": "../dist/cjs/testing/index.js",
"module": "../dist/esm5/testing/index.js",
"es2015": "../dist/esm/testing/index.js",
"module": "../dist/esm/testing/index.js",
"sideEffects": false
}

@@ -5,5 +5,4 @@ {

"main": "../dist/cjs/webSocket/index.js",
"module": "../dist/esm5/webSocket/index.js",
"es2015": "../dist/esm/webSocket/index.js",
"module": "../dist/esm/webSocket/index.js",
"sideEffects": false
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc