source: trip-planner-front/node_modules/rxjs/internal/operators/defaultIfEmpty.js@ bdd6491

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

initial commit

  • Property mode set to 100644
File size: 2.0 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 Subscriber_1 = require("../Subscriber");
17function defaultIfEmpty(defaultValue) {
18 if (defaultValue === void 0) { defaultValue = null; }
19 return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
20}
21exports.defaultIfEmpty = defaultIfEmpty;
22var DefaultIfEmptyOperator = (function () {
23 function DefaultIfEmptyOperator(defaultValue) {
24 this.defaultValue = defaultValue;
25 }
26 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
27 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
28 };
29 return DefaultIfEmptyOperator;
30}());
31var DefaultIfEmptySubscriber = (function (_super) {
32 __extends(DefaultIfEmptySubscriber, _super);
33 function DefaultIfEmptySubscriber(destination, defaultValue) {
34 var _this = _super.call(this, destination) || this;
35 _this.defaultValue = defaultValue;
36 _this.isEmpty = true;
37 return _this;
38 }
39 DefaultIfEmptySubscriber.prototype._next = function (value) {
40 this.isEmpty = false;
41 this.destination.next(value);
42 };
43 DefaultIfEmptySubscriber.prototype._complete = function () {
44 if (this.isEmpty) {
45 this.destination.next(this.defaultValue);
46 }
47 this.destination.complete();
48 };
49 return DefaultIfEmptySubscriber;
50}(Subscriber_1.Subscriber));
51//# sourceMappingURL=defaultIfEmpty.js.map
Note: See TracBrowser for help on using the repository browser.