rxjs
Advanced tools
Comparing version 7.5.3 to 7.5.4
@@ -17,23 +17,2 @@ "use strict"; | ||
})(); | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -127,2 +106,44 @@ exports.EMPTY_OBSERVER = exports.SafeSubscriber = exports.Subscriber = void 0; | ||
} | ||
var ConsumerObserver = (function () { | ||
function ConsumerObserver(partialObserver) { | ||
this.partialObserver = partialObserver; | ||
} | ||
ConsumerObserver.prototype.next = function (value) { | ||
var partialObserver = this.partialObserver; | ||
if (partialObserver.next) { | ||
try { | ||
partialObserver.next(value); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
}; | ||
ConsumerObserver.prototype.error = function (err) { | ||
var partialObserver = this.partialObserver; | ||
if (partialObserver.error) { | ||
try { | ||
partialObserver.error(err); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
else { | ||
handleUnhandledError(err); | ||
} | ||
}; | ||
ConsumerObserver.prototype.complete = function () { | ||
var partialObserver = this.partialObserver; | ||
if (partialObserver.complete) { | ||
try { | ||
partialObserver.complete(); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
}; | ||
return ConsumerObserver; | ||
}()); | ||
var SafeSubscriber = (function (_super) { | ||
@@ -132,8 +153,11 @@ __extends(SafeSubscriber, _super); | ||
var _this = _super.call(this) || this; | ||
var next; | ||
if (isFunction_1.isFunction(observerOrNext)) { | ||
next = observerOrNext; | ||
var partialObserver; | ||
if (isFunction_1.isFunction(observerOrNext) || !observerOrNext) { | ||
partialObserver = { | ||
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined, | ||
error: error !== null && error !== void 0 ? error : undefined, | ||
complete: complete !== null && complete !== void 0 ? complete : undefined, | ||
}; | ||
} | ||
else if (observerOrNext) { | ||
(next = observerOrNext.next, error = observerOrNext.error, complete = observerOrNext.complete); | ||
else { | ||
var context_1; | ||
@@ -143,15 +167,13 @@ if (_this && config_1.config.useDeprecatedNextContext) { | ||
context_1.unsubscribe = function () { return _this.unsubscribe(); }; | ||
partialObserver = { | ||
next: observerOrNext.next && bind(observerOrNext.next, context_1), | ||
error: observerOrNext.error && bind(observerOrNext.error, context_1), | ||
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1), | ||
}; | ||
} | ||
else { | ||
context_1 = observerOrNext; | ||
partialObserver = observerOrNext; | ||
} | ||
next = next && bind(next, context_1); | ||
error = error && bind(error, context_1); | ||
complete = complete && bind(complete, context_1); | ||
} | ||
_this.destination = { | ||
next: next ? wrapForErrorHandling(next, _this) : noop_1.noop, | ||
error: wrapForErrorHandling(error !== null && error !== void 0 ? error : defaultErrorHandler, _this), | ||
complete: complete ? wrapForErrorHandling(complete, _this) : noop_1.noop, | ||
}; | ||
_this.destination = new ConsumerObserver(partialObserver); | ||
return _this; | ||
@@ -162,20 +184,9 @@ } | ||
exports.SafeSubscriber = SafeSubscriber; | ||
function wrapForErrorHandling(handler, instance) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
try { | ||
handler.apply(void 0, __spreadArray([], __read(args))); | ||
} | ||
catch (err) { | ||
if (config_1.config.useDeprecatedSynchronousErrorHandling) { | ||
errorContext_1.captureError(err); | ||
} | ||
else { | ||
reportUnhandledError_1.reportUnhandledError(err); | ||
} | ||
} | ||
}; | ||
function handleUnhandledError(error) { | ||
if (config_1.config.useDeprecatedSynchronousErrorHandling) { | ||
errorContext_1.captureError(error); | ||
} | ||
else { | ||
reportUnhandledError_1.reportUnhandledError(error); | ||
} | ||
} | ||
@@ -182,0 +193,0 @@ function defaultErrorHandler(err) { |
@@ -83,11 +83,55 @@ import { isFunction } from './util/isFunction'; | ||
} | ||
class ConsumerObserver { | ||
constructor(partialObserver) { | ||
this.partialObserver = partialObserver; | ||
} | ||
next(value) { | ||
const { partialObserver } = this; | ||
if (partialObserver.next) { | ||
try { | ||
partialObserver.next(value); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
} | ||
error(err) { | ||
const { partialObserver } = this; | ||
if (partialObserver.error) { | ||
try { | ||
partialObserver.error(err); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
else { | ||
handleUnhandledError(err); | ||
} | ||
} | ||
complete() { | ||
const { partialObserver } = this; | ||
if (partialObserver.complete) { | ||
try { | ||
partialObserver.complete(); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
} | ||
} | ||
export class SafeSubscriber extends Subscriber { | ||
constructor(observerOrNext, error, complete) { | ||
super(); | ||
let next; | ||
if (isFunction(observerOrNext)) { | ||
next = observerOrNext; | ||
let partialObserver; | ||
if (isFunction(observerOrNext) || !observerOrNext) { | ||
partialObserver = { | ||
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined, | ||
error: error !== null && error !== void 0 ? error : undefined, | ||
complete: complete !== null && complete !== void 0 ? complete : undefined, | ||
}; | ||
} | ||
else if (observerOrNext) { | ||
({ next, error, complete } = observerOrNext); | ||
else { | ||
let context; | ||
@@ -97,31 +141,22 @@ if (this && config.useDeprecatedNextContext) { | ||
context.unsubscribe = () => this.unsubscribe(); | ||
partialObserver = { | ||
next: observerOrNext.next && bind(observerOrNext.next, context), | ||
error: observerOrNext.error && bind(observerOrNext.error, context), | ||
complete: observerOrNext.complete && bind(observerOrNext.complete, context), | ||
}; | ||
} | ||
else { | ||
context = observerOrNext; | ||
partialObserver = observerOrNext; | ||
} | ||
next = next && bind(next, context); | ||
error = error && bind(error, context); | ||
complete = complete && bind(complete, context); | ||
} | ||
this.destination = { | ||
next: next ? wrapForErrorHandling(next, this) : noop, | ||
error: wrapForErrorHandling(error !== null && error !== void 0 ? error : defaultErrorHandler, this), | ||
complete: complete ? wrapForErrorHandling(complete, this) : noop, | ||
}; | ||
this.destination = new ConsumerObserver(partialObserver); | ||
} | ||
} | ||
function wrapForErrorHandling(handler, instance) { | ||
return (...args) => { | ||
try { | ||
handler(...args); | ||
} | ||
catch (err) { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
captureError(err); | ||
} | ||
else { | ||
reportUnhandledError(err); | ||
} | ||
} | ||
}; | ||
function handleUnhandledError(error) { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
captureError(error); | ||
} | ||
else { | ||
reportUnhandledError(error); | ||
} | ||
} | ||
@@ -128,0 +163,0 @@ function defaultErrorHandler(err) { |
@@ -1,2 +0,2 @@ | ||
import { __extends, __read, __spreadArray } from "tslib"; | ||
import { __extends } from "tslib"; | ||
import { isFunction } from './util/isFunction'; | ||
@@ -88,2 +88,44 @@ import { isSubscription, Subscription } from './Subscription'; | ||
} | ||
var ConsumerObserver = (function () { | ||
function ConsumerObserver(partialObserver) { | ||
this.partialObserver = partialObserver; | ||
} | ||
ConsumerObserver.prototype.next = function (value) { | ||
var partialObserver = this.partialObserver; | ||
if (partialObserver.next) { | ||
try { | ||
partialObserver.next(value); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
}; | ||
ConsumerObserver.prototype.error = function (err) { | ||
var partialObserver = this.partialObserver; | ||
if (partialObserver.error) { | ||
try { | ||
partialObserver.error(err); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
else { | ||
handleUnhandledError(err); | ||
} | ||
}; | ||
ConsumerObserver.prototype.complete = function () { | ||
var partialObserver = this.partialObserver; | ||
if (partialObserver.complete) { | ||
try { | ||
partialObserver.complete(); | ||
} | ||
catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
}; | ||
return ConsumerObserver; | ||
}()); | ||
var SafeSubscriber = (function (_super) { | ||
@@ -93,8 +135,11 @@ __extends(SafeSubscriber, _super); | ||
var _this = _super.call(this) || this; | ||
var next; | ||
if (isFunction(observerOrNext)) { | ||
next = observerOrNext; | ||
var partialObserver; | ||
if (isFunction(observerOrNext) || !observerOrNext) { | ||
partialObserver = { | ||
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined, | ||
error: error !== null && error !== void 0 ? error : undefined, | ||
complete: complete !== null && complete !== void 0 ? complete : undefined, | ||
}; | ||
} | ||
else if (observerOrNext) { | ||
(next = observerOrNext.next, error = observerOrNext.error, complete = observerOrNext.complete); | ||
else { | ||
var context_1; | ||
@@ -104,15 +149,13 @@ if (_this && config.useDeprecatedNextContext) { | ||
context_1.unsubscribe = function () { return _this.unsubscribe(); }; | ||
partialObserver = { | ||
next: observerOrNext.next && bind(observerOrNext.next, context_1), | ||
error: observerOrNext.error && bind(observerOrNext.error, context_1), | ||
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1), | ||
}; | ||
} | ||
else { | ||
context_1 = observerOrNext; | ||
partialObserver = observerOrNext; | ||
} | ||
next = next && bind(next, context_1); | ||
error = error && bind(error, context_1); | ||
complete = complete && bind(complete, context_1); | ||
} | ||
_this.destination = { | ||
next: next ? wrapForErrorHandling(next, _this) : noop, | ||
error: wrapForErrorHandling(error !== null && error !== void 0 ? error : defaultErrorHandler, _this), | ||
complete: complete ? wrapForErrorHandling(complete, _this) : noop, | ||
}; | ||
_this.destination = new ConsumerObserver(partialObserver); | ||
return _this; | ||
@@ -123,20 +166,9 @@ } | ||
export { SafeSubscriber }; | ||
function wrapForErrorHandling(handler, instance) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
try { | ||
handler.apply(void 0, __spreadArray([], __read(args))); | ||
} | ||
catch (err) { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
captureError(err); | ||
} | ||
else { | ||
reportUnhandledError(err); | ||
} | ||
} | ||
}; | ||
function handleUnhandledError(error) { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
captureError(error); | ||
} | ||
else { | ||
reportUnhandledError(error); | ||
} | ||
} | ||
@@ -143,0 +175,0 @@ function defaultErrorHandler(err) { |
{ | ||
"name": "rxjs", | ||
"version": "7.5.3", | ||
"version": "7.5.4", | ||
"description": "Reactive Extensions for modern JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -150,2 +150,45 @@ import { isFunction } from './util/isFunction'; | ||
/** | ||
* Internal optimization only, DO NOT EXPOSE. | ||
* @internal | ||
*/ | ||
class ConsumerObserver<T> implements Observer<T> { | ||
constructor(private partialObserver: Partial<Observer<T>>) {} | ||
next(value: T): void { | ||
const { partialObserver } = this; | ||
if (partialObserver.next) { | ||
try { | ||
partialObserver.next(value); | ||
} catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
} | ||
error(err: any): void { | ||
const { partialObserver } = this; | ||
if (partialObserver.error) { | ||
try { | ||
partialObserver.error(err); | ||
} catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} else { | ||
handleUnhandledError(err); | ||
} | ||
} | ||
complete(): void { | ||
const { partialObserver } = this; | ||
if (partialObserver.complete) { | ||
try { | ||
partialObserver.complete(); | ||
} catch (error) { | ||
handleUnhandledError(error); | ||
} | ||
} | ||
} | ||
} | ||
export class SafeSubscriber<T> extends Subscriber<T> { | ||
@@ -159,14 +202,13 @@ constructor( | ||
let next: ((value: T) => void) | undefined; | ||
if (isFunction(observerOrNext)) { | ||
let partialObserver: Partial<Observer<T>>; | ||
if (isFunction(observerOrNext) || !observerOrNext) { | ||
// The first argument is a function, not an observer. The next | ||
// two arguments *could* be observers, or they could be empty. | ||
next = observerOrNext; | ||
} else if (observerOrNext) { | ||
// The first argument is an observer object, we have to pull the handlers | ||
// off and capture the owner object as the context. That is because we're | ||
// going to put them all in a new destination with ensured methods | ||
// for `next`, `error`, and `complete`. That's part of what makes this | ||
// the "Safe" Subscriber. | ||
({ next, error, complete } = observerOrNext); | ||
partialObserver = { | ||
next: observerOrNext ?? undefined, | ||
error: error ?? undefined, | ||
complete: complete ?? undefined, | ||
}; | ||
} else { | ||
// The first argument is a partial observer. | ||
let context: any; | ||
@@ -179,42 +221,29 @@ if (this && config.useDeprecatedNextContext) { | ||
context.unsubscribe = () => this.unsubscribe(); | ||
partialObserver = { | ||
next: observerOrNext.next && bind(observerOrNext.next, context), | ||
error: observerOrNext.error && bind(observerOrNext.error, context), | ||
complete: observerOrNext.complete && bind(observerOrNext.complete, context), | ||
}; | ||
} else { | ||
context = observerOrNext; | ||
// The "normal" path. Just use the partial observer directly. | ||
partialObserver = observerOrNext; | ||
} | ||
next = next && bind(next, context); | ||
error = error && bind(error, context); | ||
complete = complete && bind(complete, context); | ||
} | ||
// Once we set the destination, the superclass `Subscriber` will | ||
// do it's magic in the `_next`, `_error`, and `_complete` methods. | ||
this.destination = { | ||
next: next ? wrapForErrorHandling(next, this) : noop, | ||
error: wrapForErrorHandling(error ?? defaultErrorHandler, this), | ||
complete: complete ? wrapForErrorHandling(complete, this) : noop, | ||
}; | ||
// Wrap the partial observer to ensure it's a full observer, and | ||
// make sure proper error handling is accounted for. | ||
this.destination = new ConsumerObserver(partialObserver); | ||
} | ||
} | ||
/** | ||
* Wraps a user-provided handler (or our {@link defaultErrorHandler} in one case) to | ||
* ensure that any thrown errors are caught and handled appropriately. | ||
* | ||
* @param handler The handler to wrap | ||
* @param instance The SafeSubscriber instance we're going to mark if there's an error. | ||
*/ | ||
function wrapForErrorHandling(handler: (arg?: any) => void, instance: SafeSubscriber<any>) { | ||
return (...args: any[]) => { | ||
try { | ||
handler(...args); | ||
} catch (err) { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
captureError(err); | ||
} else { | ||
// Ideal path, we report this as an unhandled error, | ||
// which is thrown on a new call stack. | ||
reportUnhandledError(err); | ||
} | ||
} | ||
}; | ||
function handleUnhandledError(error: any) { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
captureError(error); | ||
} else { | ||
// Ideal path, we report this as an unhandled error, | ||
// which is thrown on a new call stack. | ||
reportUnhandledError(error); | ||
} | ||
} | ||
/** | ||
@@ -221,0 +250,0 @@ * An error handler used when no error handler was supplied |
Sorry, the diff of this file is too big to display
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 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
4474021
57360