Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

filter.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { Subscriber } from '../Subscriber';
  4. export function filter(predicate, thisArg) {
  5. return function filterOperatorFunction(source) {
  6. return source.lift(new FilterOperator(predicate, thisArg));
  7. };
  8. }
  9. var FilterOperator = /*@__PURE__*/ (function () {
  10. function FilterOperator(predicate, thisArg) {
  11. this.predicate = predicate;
  12. this.thisArg = thisArg;
  13. }
  14. FilterOperator.prototype.call = function (subscriber, source) {
  15. return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
  16. };
  17. return FilterOperator;
  18. }());
  19. var FilterSubscriber = /*@__PURE__*/ (function (_super) {
  20. tslib_1.__extends(FilterSubscriber, _super);
  21. function FilterSubscriber(destination, predicate, thisArg) {
  22. var _this = _super.call(this, destination) || this;
  23. _this.predicate = predicate;
  24. _this.thisArg = thisArg;
  25. _this.count = 0;
  26. return _this;
  27. }
  28. FilterSubscriber.prototype._next = function (value) {
  29. var result;
  30. try {
  31. result = this.predicate.call(this.thisArg, value, this.count++);
  32. }
  33. catch (err) {
  34. this.destination.error(err);
  35. return;
  36. }
  37. if (result) {
  38. this.destination.next(value);
  39. }
  40. };
  41. return FilterSubscriber;
  42. }(Subscriber));
  43. //# sourceMappingURL=filter.js.map