source: trip-planner-front/node_modules/rxjs/internal/operators/take.js@ 6a3a178

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

initial commit

  • Property mode set to 100644
File size: 2.1 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");
17var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
18var empty_1 = require("../observable/empty");
19function take(count) {
20 return function (source) {
21 if (count === 0) {
22 return empty_1.empty();
23 }
24 else {
25 return source.lift(new TakeOperator(count));
26 }
27 };
28}
29exports.take = take;
30var TakeOperator = (function () {
31 function TakeOperator(total) {
32 this.total = total;
33 if (this.total < 0) {
34 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
35 }
36 }
37 TakeOperator.prototype.call = function (subscriber, source) {
38 return source.subscribe(new TakeSubscriber(subscriber, this.total));
39 };
40 return TakeOperator;
41}());
42var TakeSubscriber = (function (_super) {
43 __extends(TakeSubscriber, _super);
44 function TakeSubscriber(destination, total) {
45 var _this = _super.call(this, destination) || this;
46 _this.total = total;
47 _this.count = 0;
48 return _this;
49 }
50 TakeSubscriber.prototype._next = function (value) {
51 var total = this.total;
52 var count = ++this.count;
53 if (count <= total) {
54 this.destination.next(value);
55 if (count === total) {
56 this.destination.complete();
57 this.unsubscribe();
58 }
59 }
60 };
61 return TakeSubscriber;
62}(Subscriber_1.Subscriber));
63//# sourceMappingURL=take.js.map
Note: See TracBrowser for help on using the repository browser.