This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/rxjs/internal/operators/find.js

73 lines
2.8 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Subscriber_1 = require("../Subscriber");
function find(predicate, thisArg) {
if (typeof predicate !== 'function') {
throw new TypeError('predicate is not a function');
}
return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
}
exports.find = find;
var FindValueOperator = (function () {
function FindValueOperator(predicate, source, yieldIndex, thisArg) {
this.predicate = predicate;
this.source = source;
this.yieldIndex = yieldIndex;
this.thisArg = thisArg;
}
FindValueOperator.prototype.call = function (observer, source) {
return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
};
return FindValueOperator;
}());
exports.FindValueOperator = FindValueOperator;
var FindValueSubscriber = (function (_super) {
__extends(FindValueSubscriber, _super);
function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
var _this = _super.call(this, destination) || this;
_this.predicate = predicate;
_this.source = source;
_this.yieldIndex = yieldIndex;
_this.thisArg = thisArg;
_this.index = 0;
return _this;
}
FindValueSubscriber.prototype.notifyComplete = function (value) {
var destination = this.destination;
destination.next(value);
destination.complete();
this.unsubscribe();
};
FindValueSubscriber.prototype._next = function (value) {
var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
var index = this.index++;
try {
var result = predicate.call(thisArg || this, value, index, this.source);
if (result) {
this.notifyComplete(this.yieldIndex ? index : value);
}
}
catch (err) {
this.destination.error(err);
}
};
FindValueSubscriber.prototype._complete = function () {
this.notifyComplete(this.yieldIndex ? -1 : undefined);
};
return FindValueSubscriber;
}(Subscriber_1.Subscriber));
exports.FindValueSubscriber = FindValueSubscriber;
//# sourceMappingURL=find.js.map