source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/take.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.6 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber,_util_ArgumentOutOfRangeError,_observable_empty PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4import { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';
5import { empty } from '../observable/empty';
6export function take(count) {
7 return function (source) {
8 if (count === 0) {
9 return empty();
10 }
11 else {
12 return source.lift(new TakeOperator(count));
13 }
14 };
15}
16var TakeOperator = /*@__PURE__*/ (function () {
17 function TakeOperator(total) {
18 this.total = total;
19 if (this.total < 0) {
20 throw new ArgumentOutOfRangeError;
21 }
22 }
23 TakeOperator.prototype.call = function (subscriber, source) {
24 return source.subscribe(new TakeSubscriber(subscriber, this.total));
25 };
26 return TakeOperator;
27}());
28var TakeSubscriber = /*@__PURE__*/ (function (_super) {
29 tslib_1.__extends(TakeSubscriber, _super);
30 function TakeSubscriber(destination, total) {
31 var _this = _super.call(this, destination) || this;
32 _this.total = total;
33 _this.count = 0;
34 return _this;
35 }
36 TakeSubscriber.prototype._next = function (value) {
37 var total = this.total;
38 var count = ++this.count;
39 if (count <= total) {
40 this.destination.next(value);
41 if (count === total) {
42 this.destination.complete();
43 this.unsubscribe();
44 }
45 }
46 };
47 return TakeSubscriber;
48}(Subscriber));
49//# sourceMappingURL=take.js.map
Note: See TracBrowser for help on using the repository browser.