a zip code crypto-currency system good for red ONLY

timeInterval.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /** PURE_IMPORTS_START .._Subscriber,.._scheduler_async PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Subscriber } from '../Subscriber';
  10. import { async } from '../scheduler/async';
  11. export function timeInterval(scheduler) {
  12. if (scheduler === void 0) {
  13. scheduler = async;
  14. }
  15. return function (source) { return source.lift(new TimeIntervalOperator(scheduler)); };
  16. }
  17. export var TimeInterval = /*@__PURE__*/ (/*@__PURE__*/ function () {
  18. function TimeInterval(value, interval) {
  19. this.value = value;
  20. this.interval = interval;
  21. }
  22. return TimeInterval;
  23. }());
  24. ;
  25. var TimeIntervalOperator = /*@__PURE__*/ (/*@__PURE__*/ function () {
  26. function TimeIntervalOperator(scheduler) {
  27. this.scheduler = scheduler;
  28. }
  29. TimeIntervalOperator.prototype.call = function (observer, source) {
  30. return source.subscribe(new TimeIntervalSubscriber(observer, this.scheduler));
  31. };
  32. return TimeIntervalOperator;
  33. }());
  34. /**
  35. * We need this JSDoc comment for affecting ESDoc.
  36. * @ignore
  37. * @extends {Ignored}
  38. */
  39. var TimeIntervalSubscriber = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  40. __extends(TimeIntervalSubscriber, _super);
  41. function TimeIntervalSubscriber(destination, scheduler) {
  42. _super.call(this, destination);
  43. this.scheduler = scheduler;
  44. this.lastTime = 0;
  45. this.lastTime = scheduler.now();
  46. }
  47. TimeIntervalSubscriber.prototype._next = function (value) {
  48. var now = this.scheduler.now();
  49. var span = now - this.lastTime;
  50. this.lastTime = now;
  51. this.destination.next(new TimeInterval(value, span));
  52. };
  53. return TimeIntervalSubscriber;
  54. }(Subscriber));
  55. //# sourceMappingURL=timeInterval.js.map