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.

map.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */
  2. import * as tslib_1 from "tslib";
  3. import { Subscriber } from '../Subscriber';
  4. export function map(project, thisArg) {
  5. return function mapOperation(source) {
  6. if (typeof project !== 'function') {
  7. throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
  8. }
  9. return source.lift(new MapOperator(project, thisArg));
  10. };
  11. }
  12. var MapOperator = /*@__PURE__*/ (function () {
  13. function MapOperator(project, thisArg) {
  14. this.project = project;
  15. this.thisArg = thisArg;
  16. }
  17. MapOperator.prototype.call = function (subscriber, source) {
  18. return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
  19. };
  20. return MapOperator;
  21. }());
  22. export { MapOperator };
  23. var MapSubscriber = /*@__PURE__*/ (function (_super) {
  24. tslib_1.__extends(MapSubscriber, _super);
  25. function MapSubscriber(destination, project, thisArg) {
  26. var _this = _super.call(this, destination) || this;
  27. _this.project = project;
  28. _this.count = 0;
  29. _this.thisArg = thisArg || _this;
  30. return _this;
  31. }
  32. MapSubscriber.prototype._next = function (value) {
  33. var result;
  34. try {
  35. result = this.project.call(this.thisArg, value, this.count++);
  36. }
  37. catch (err) {
  38. this.destination.error(err);
  39. return;
  40. }
  41. this.destination.next(result);
  42. };
  43. return MapSubscriber;
  44. }(Subscriber));
  45. //# sourceMappingURL=map.js.map