source: trip-planner-front/node_modules/rxjs/internal/operators/throwIfEmpty.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var EmptyError_1 = require("../util/EmptyError");
17var Subscriber_1 = require("../Subscriber");
18function throwIfEmpty(errorFactory) {
19 if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
20 return function (source) {
21 return source.lift(new ThrowIfEmptyOperator(errorFactory));
22 };
23}
24exports.throwIfEmpty = throwIfEmpty;
25var ThrowIfEmptyOperator = (function () {
26 function ThrowIfEmptyOperator(errorFactory) {
27 this.errorFactory = errorFactory;
28 }
29 ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
30 return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
31 };
32 return ThrowIfEmptyOperator;
33}());
34var ThrowIfEmptySubscriber = (function (_super) {
35 __extends(ThrowIfEmptySubscriber, _super);
36 function ThrowIfEmptySubscriber(destination, errorFactory) {
37 var _this = _super.call(this, destination) || this;
38 _this.errorFactory = errorFactory;
39 _this.hasValue = false;
40 return _this;
41 }
42 ThrowIfEmptySubscriber.prototype._next = function (value) {
43 this.hasValue = true;
44 this.destination.next(value);
45 };
46 ThrowIfEmptySubscriber.prototype._complete = function () {
47 if (!this.hasValue) {
48 var err = void 0;
49 try {
50 err = this.errorFactory();
51 }
52 catch (e) {
53 err = e;
54 }
55 this.destination.error(err);
56 }
57 else {
58 return this.destination.complete();
59 }
60 };
61 return ThrowIfEmptySubscriber;
62}(Subscriber_1.Subscriber));
63function defaultErrorFactory() {
64 return new EmptyError_1.EmptyError();
65}
66//# sourceMappingURL=throwIfEmpty.js.map
Note: See TracBrowser for help on using the repository browser.