timeInterval.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /** PURE_IMPORTS_START _scheduler_async,_scan,_observable_defer,_map PURE_IMPORTS_END */
  2. import { async } from '../scheduler/async';
  3. import { scan } from './scan';
  4. import { defer } from '../observable/defer';
  5. import { map } from './map';
  6. export function timeInterval(scheduler) {
  7. if (scheduler === void 0) {
  8. scheduler = async;
  9. }
  10. return function (source) {
  11. return defer(function () {
  12. return source.pipe(scan(function (_a, value) {
  13. var current = _a.current;
  14. return ({ value: value, current: scheduler.now(), last: current });
  15. }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
  16. var current = _a.current, last = _a.last, value = _a.value;
  17. return new TimeInterval(value, current - last);
  18. }));
  19. });
  20. };
  21. }
  22. var TimeInterval = /*@__PURE__*/ (function () {
  23. function TimeInterval(value, interval) {
  24. this.value = value;
  25. this.interval = interval;
  26. }
  27. return TimeInterval;
  28. }());
  29. export { TimeInterval };
  30. //# sourceMappingURL=timeInterval.js.map