Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

map.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. }
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var Subscriber_1 = require("../Subscriber");
  17. function map(project, thisArg) {
  18. return function mapOperation(source) {
  19. if (typeof project !== 'function') {
  20. throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
  21. }
  22. return source.lift(new MapOperator(project, thisArg));
  23. };
  24. }
  25. exports.map = map;
  26. var MapOperator = (function () {
  27. function MapOperator(project, thisArg) {
  28. this.project = project;
  29. this.thisArg = thisArg;
  30. }
  31. MapOperator.prototype.call = function (subscriber, source) {
  32. return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
  33. };
  34. return MapOperator;
  35. }());
  36. exports.MapOperator = MapOperator;
  37. var MapSubscriber = (function (_super) {
  38. __extends(MapSubscriber, _super);
  39. function MapSubscriber(destination, project, thisArg) {
  40. var _this = _super.call(this, destination) || this;
  41. _this.project = project;
  42. _this.count = 0;
  43. _this.thisArg = thisArg || _this;
  44. return _this;
  45. }
  46. MapSubscriber.prototype._next = function (value) {
  47. var result;
  48. try {
  49. result = this.project.call(this.thisArg, value, this.count++);
  50. }
  51. catch (err) {
  52. this.destination.error(err);
  53. return;
  54. }
  55. this.destination.next(result);
  56. };
  57. return MapSubscriber;
  58. }(Subscriber_1.Subscriber));
  59. //# sourceMappingURL=map.js.map