Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / throwIfEmpty.js
1 /** PURE_IMPORTS_START tslib,_util_EmptyError,_Subscriber PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { EmptyError } from '../util/EmptyError';
4 import { Subscriber } from '../Subscriber';
5 export 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 }
13 var 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 }());
22 var 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));
51 function defaultErrorFactory() {
52     return new EmptyError();
53 }
54 //# sourceMappingURL=throwIfEmpty.js.map