source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/throwIfEmpty.js

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

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/** PURE_IMPORTS_START tslib,_util_EmptyError,_Subscriber PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { EmptyError } from '../util/EmptyError';
4import { Subscriber } from '../Subscriber';
5export function throwIfEmpty(errorFactory) {
6 if (errorFactory === void 0) {
7 errorFactory = defaultErrorFactory;
8 }
9 return function (source) {
10 return source.lift(new ThrowIfEmptyOperator(errorFactory));
11 };
12}
13var ThrowIfEmptyOperator = /*@__PURE__*/ (function () {
14 function ThrowIfEmptyOperator(errorFactory) {
15 this.errorFactory = errorFactory;
16 }
17 ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
18 return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
19 };
20 return ThrowIfEmptyOperator;
21}());
22var ThrowIfEmptySubscriber = /*@__PURE__*/ (function (_super) {
23 tslib_1.__extends(ThrowIfEmptySubscriber, _super);
24 function ThrowIfEmptySubscriber(destination, errorFactory) {
25 var _this = _super.call(this, destination) || this;
26 _this.errorFactory = errorFactory;
27 _this.hasValue = false;
28 return _this;
29 }
30 ThrowIfEmptySubscriber.prototype._next = function (value) {
31 this.hasValue = true;
32 this.destination.next(value);
33 };
34 ThrowIfEmptySubscriber.prototype._complete = function () {
35 if (!this.hasValue) {
36 var err = void 0;
37 try {
38 err = this.errorFactory();
39 }
40 catch (e) {
41 err = e;
42 }
43 this.destination.error(err);
44 }
45 else {
46 return this.destination.complete();
47 }
48 };
49 return ThrowIfEmptySubscriber;
50}(Subscriber));
51function defaultErrorFactory() {
52 return new EmptyError();
53}
54//# sourceMappingURL=throwIfEmpty.js.map
Note: See TracBrowser for help on using the repository browser.