a zip code crypto-currency system good for red ONLY

auditTime.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. var async_1 = require('../scheduler/async');
  3. var audit_1 = require('./audit');
  4. var timer_1 = require('../observable/timer');
  5. /**
  6. * Ignores source values for `duration` milliseconds, then emits the most recent
  7. * value from the source Observable, then repeats this process.
  8. *
  9. * <span class="informal">When it sees a source values, it ignores that plus
  10. * the next ones for `duration` milliseconds, and then it emits the most recent
  11. * value from the source.</span>
  12. *
  13. * <img src="./img/auditTime.png" width="100%">
  14. *
  15. * `auditTime` is similar to `throttleTime`, but emits the last value from the
  16. * silenced time window, instead of the first value. `auditTime` emits the most
  17. * recent value from the source Observable on the output Observable as soon as
  18. * its internal timer becomes disabled, and ignores source values while the
  19. * timer is enabled. Initially, the timer is disabled. As soon as the first
  20. * source value arrives, the timer is enabled. After `duration` milliseconds (or
  21. * the time unit determined internally by the optional `scheduler`) has passed,
  22. * the timer is disabled, then the most recent source value is emitted on the
  23. * output Observable, and this process repeats for the next source value.
  24. * Optionally takes a {@link IScheduler} for managing timers.
  25. *
  26. * @example <caption>Emit clicks at a rate of at most one click per second</caption>
  27. * var clicks = Rx.Observable.fromEvent(document, 'click');
  28. * var result = clicks.auditTime(1000);
  29. * result.subscribe(x => console.log(x));
  30. *
  31. * @see {@link audit}
  32. * @see {@link debounceTime}
  33. * @see {@link delay}
  34. * @see {@link sampleTime}
  35. * @see {@link throttleTime}
  36. *
  37. * @param {number} duration Time to wait before emitting the most recent source
  38. * value, measured in milliseconds or the time unit determined internally
  39. * by the optional `scheduler`.
  40. * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for
  41. * managing the timers that handle the rate-limiting behavior.
  42. * @return {Observable<T>} An Observable that performs rate-limiting of
  43. * emissions from the source Observable.
  44. * @method auditTime
  45. * @owner Observable
  46. */
  47. function auditTime(duration, scheduler) {
  48. if (scheduler === void 0) { scheduler = async_1.async; }
  49. return audit_1.audit(function () { return timer_1.timer(duration, scheduler); });
  50. }
  51. exports.auditTime = auditTime;
  52. //# sourceMappingURL=auditTime.js.map