Initial commit
This commit is contained in:
186
node/TestCli/node_modules/rxjs/dist/cjs/internal/Subscriber.js
generated
vendored
Normal file
186
node/TestCli/node_modules/rxjs/dist/cjs/internal/Subscriber.js
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
"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 __());
|
||||
};
|
||||
})();
|
||||
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 });
|
||||
exports.EMPTY_OBSERVER = exports.SafeSubscriber = exports.Subscriber = void 0;
|
||||
var isFunction_1 = require("./util/isFunction");
|
||||
var Subscription_1 = require("./Subscription");
|
||||
var config_1 = require("./config");
|
||||
var reportUnhandledError_1 = require("./util/reportUnhandledError");
|
||||
var noop_1 = require("./util/noop");
|
||||
var NotificationFactories_1 = require("./NotificationFactories");
|
||||
var timeoutProvider_1 = require("./scheduler/timeoutProvider");
|
||||
var errorContext_1 = require("./util/errorContext");
|
||||
var Subscriber = (function (_super) {
|
||||
__extends(Subscriber, _super);
|
||||
function Subscriber(destination) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.isStopped = false;
|
||||
if (destination) {
|
||||
_this.destination = destination;
|
||||
if (Subscription_1.isSubscription(destination)) {
|
||||
destination.add(_this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_this.destination = exports.EMPTY_OBSERVER;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
Subscriber.create = function (next, error, complete) {
|
||||
return new SafeSubscriber(next, error, complete);
|
||||
};
|
||||
Subscriber.prototype.next = function (value) {
|
||||
if (this.isStopped) {
|
||||
handleStoppedNotification(NotificationFactories_1.nextNotification(value), this);
|
||||
}
|
||||
else {
|
||||
this._next(value);
|
||||
}
|
||||
};
|
||||
Subscriber.prototype.error = function (err) {
|
||||
if (this.isStopped) {
|
||||
handleStoppedNotification(NotificationFactories_1.errorNotification(err), this);
|
||||
}
|
||||
else {
|
||||
this.isStopped = true;
|
||||
this._error(err);
|
||||
}
|
||||
};
|
||||
Subscriber.prototype.complete = function () {
|
||||
if (this.isStopped) {
|
||||
handleStoppedNotification(NotificationFactories_1.COMPLETE_NOTIFICATION, this);
|
||||
}
|
||||
else {
|
||||
this.isStopped = true;
|
||||
this._complete();
|
||||
}
|
||||
};
|
||||
Subscriber.prototype.unsubscribe = function () {
|
||||
if (!this.closed) {
|
||||
this.isStopped = true;
|
||||
_super.prototype.unsubscribe.call(this);
|
||||
this.destination = null;
|
||||
}
|
||||
};
|
||||
Subscriber.prototype._next = function (value) {
|
||||
this.destination.next(value);
|
||||
};
|
||||
Subscriber.prototype._error = function (err) {
|
||||
try {
|
||||
this.destination.error(err);
|
||||
}
|
||||
finally {
|
||||
this.unsubscribe();
|
||||
}
|
||||
};
|
||||
Subscriber.prototype._complete = function () {
|
||||
try {
|
||||
this.destination.complete();
|
||||
}
|
||||
finally {
|
||||
this.unsubscribe();
|
||||
}
|
||||
};
|
||||
return Subscriber;
|
||||
}(Subscription_1.Subscription));
|
||||
exports.Subscriber = Subscriber;
|
||||
var SafeSubscriber = (function (_super) {
|
||||
__extends(SafeSubscriber, _super);
|
||||
function SafeSubscriber(observerOrNext, error, complete) {
|
||||
var _this = _super.call(this) || this;
|
||||
var next;
|
||||
if (isFunction_1.isFunction(observerOrNext)) {
|
||||
next = observerOrNext;
|
||||
}
|
||||
else if (observerOrNext) {
|
||||
(next = observerOrNext.next, error = observerOrNext.error, complete = observerOrNext.complete);
|
||||
var context_1;
|
||||
if (_this && config_1.config.useDeprecatedNextContext) {
|
||||
context_1 = Object.create(observerOrNext);
|
||||
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
||||
}
|
||||
else {
|
||||
context_1 = observerOrNext;
|
||||
}
|
||||
next = next === null || next === void 0 ? void 0 : next.bind(context_1);
|
||||
error = error === null || error === void 0 ? void 0 : error.bind(context_1);
|
||||
complete = complete === null || complete === void 0 ? void 0 : complete.bind(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,
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
return SafeSubscriber;
|
||||
}(Subscriber));
|
||||
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 defaultErrorHandler(err) {
|
||||
throw err;
|
||||
}
|
||||
function handleStoppedNotification(notification, subscriber) {
|
||||
var onStoppedNotification = config_1.config.onStoppedNotification;
|
||||
onStoppedNotification && timeoutProvider_1.timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); });
|
||||
}
|
||||
exports.EMPTY_OBSERVER = {
|
||||
closed: true,
|
||||
next: noop_1.noop,
|
||||
error: defaultErrorHandler,
|
||||
complete: noop_1.noop,
|
||||
};
|
||||
//# sourceMappingURL=Subscriber.js.map
|
||||
Reference in New Issue
Block a user