a zip code crypto-currency system good for red ONLY

mapTo.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var Subscriber_1 = require('../Subscriber');
  8. /**
  9. * Emits the given constant value on the output Observable every time the source
  10. * Observable emits a value.
  11. *
  12. * <span class="informal">Like {@link map}, but it maps every source value to
  13. * the same output value every time.</span>
  14. *
  15. * <img src="./img/mapTo.png" width="100%">
  16. *
  17. * Takes a constant `value` as argument, and emits that whenever the source
  18. * Observable emits a value. In other words, ignores the actual source value,
  19. * and simply uses the emission moment to know when to emit the given `value`.
  20. *
  21. * @example <caption>Map every click to the string 'Hi'</caption>
  22. * var clicks = Rx.Observable.fromEvent(document, 'click');
  23. * var greetings = clicks.mapTo('Hi');
  24. * greetings.subscribe(x => console.log(x));
  25. *
  26. * @see {@link map}
  27. *
  28. * @param {any} value The value to map each source value to.
  29. * @return {Observable} An Observable that emits the given `value` every time
  30. * the source Observable emits something.
  31. * @method mapTo
  32. * @owner Observable
  33. */
  34. function mapTo(value) {
  35. return function (source) { return source.lift(new MapToOperator(value)); };
  36. }
  37. exports.mapTo = mapTo;
  38. var MapToOperator = (function () {
  39. function MapToOperator(value) {
  40. this.value = value;
  41. }
  42. MapToOperator.prototype.call = function (subscriber, source) {
  43. return source.subscribe(new MapToSubscriber(subscriber, this.value));
  44. };
  45. return MapToOperator;
  46. }());
  47. /**
  48. * We need this JSDoc comment for affecting ESDoc.
  49. * @ignore
  50. * @extends {Ignored}
  51. */
  52. var MapToSubscriber = (function (_super) {
  53. __extends(MapToSubscriber, _super);
  54. function MapToSubscriber(destination, value) {
  55. _super.call(this, destination);
  56. this.value = value;
  57. }
  58. MapToSubscriber.prototype._next = function (x) {
  59. this.destination.next(this.value);
  60. };
  61. return MapToSubscriber;
  62. }(Subscriber_1.Subscriber));
  63. //# sourceMappingURL=mapTo.js.map