2 var __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);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Subscriber_1 = require("../Subscriber");
17 var noop_1 = require("../util/noop");
18 var isFunction_1 = require("../util/isFunction");
19 function tap(nextOrObserver, error, complete) {
20 return function tapOperatorFunction(source) {
21 return source.lift(new DoOperator(nextOrObserver, error, complete));
25 var DoOperator = (function () {
26 function DoOperator(nextOrObserver, error, complete) {
27 this.nextOrObserver = nextOrObserver;
29 this.complete = complete;
31 DoOperator.prototype.call = function (subscriber, source) {
32 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
36 var TapSubscriber = (function (_super) {
37 __extends(TapSubscriber, _super);
38 function TapSubscriber(destination, observerOrNext, error, complete) {
39 var _this = _super.call(this, destination) || this;
40 _this._tapNext = noop_1.noop;
41 _this._tapError = noop_1.noop;
42 _this._tapComplete = noop_1.noop;
43 _this._tapError = error || noop_1.noop;
44 _this._tapComplete = complete || noop_1.noop;
45 if (isFunction_1.isFunction(observerOrNext)) {
46 _this._context = _this;
47 _this._tapNext = observerOrNext;
49 else if (observerOrNext) {
50 _this._context = observerOrNext;
51 _this._tapNext = observerOrNext.next || noop_1.noop;
52 _this._tapError = observerOrNext.error || noop_1.noop;
53 _this._tapComplete = observerOrNext.complete || noop_1.noop;
57 TapSubscriber.prototype._next = function (value) {
59 this._tapNext.call(this._context, value);
62 this.destination.error(err);
65 this.destination.next(value);
67 TapSubscriber.prototype._error = function (err) {
69 this._tapError.call(this._context, err);
72 this.destination.error(err);
75 this.destination.error(err);
77 TapSubscriber.prototype._complete = function () {
79 this._tapComplete.call(this._context);
82 this.destination.error(err);
85 return this.destination.complete();
88 }(Subscriber_1.Subscriber));
89 //# sourceMappingURL=tap.js.map