source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/find.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { Subscriber } from '../Subscriber';
4export function find(predicate, thisArg) {
5 if (typeof predicate !== 'function') {
6 throw new TypeError('predicate is not a function');
7 }
8 return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
9}
10var FindValueOperator = /*@__PURE__*/ (function () {
11 function FindValueOperator(predicate, source, yieldIndex, thisArg) {
12 this.predicate = predicate;
13 this.source = source;
14 this.yieldIndex = yieldIndex;
15 this.thisArg = thisArg;
16 }
17 FindValueOperator.prototype.call = function (observer, source) {
18 return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
19 };
20 return FindValueOperator;
21}());
22export { FindValueOperator };
23var FindValueSubscriber = /*@__PURE__*/ (function (_super) {
24 tslib_1.__extends(FindValueSubscriber, _super);
25 function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
26 var _this = _super.call(this, destination) || this;
27 _this.predicate = predicate;
28 _this.source = source;
29 _this.yieldIndex = yieldIndex;
30 _this.thisArg = thisArg;
31 _this.index = 0;
32 return _this;
33 }
34 FindValueSubscriber.prototype.notifyComplete = function (value) {
35 var destination = this.destination;
36 destination.next(value);
37 destination.complete();
38 this.unsubscribe();
39 };
40 FindValueSubscriber.prototype._next = function (value) {
41 var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
42 var index = this.index++;
43 try {
44 var result = predicate.call(thisArg || this, value, index, this.source);
45 if (result) {
46 this.notifyComplete(this.yieldIndex ? index : value);
47 }
48 }
49 catch (err) {
50 this.destination.error(err);
51 }
52 };
53 FindValueSubscriber.prototype._complete = function () {
54 this.notifyComplete(this.yieldIndex ? -1 : undefined);
55 };
56 return FindValueSubscriber;
57}(Subscriber));
58export { FindValueSubscriber };
59//# sourceMappingURL=find.js.map
Note: See TracBrowser for help on using the repository browser.