wishthis/node_modules/rxjs/dist/esm/internal/operators/timeInterval.js
2022-06-08 12:36:39 +02:00

21 lines
No EOL
739 B
JavaScript

import { asyncScheduler } from '../scheduler/async';
import { operate } from '../util/lift';
import { createOperatorSubscriber } from './OperatorSubscriber';
export function timeInterval(scheduler = asyncScheduler) {
return operate((source, subscriber) => {
let last = scheduler.now();
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
const now = scheduler.now();
const interval = now - last;
last = now;
subscriber.next(new TimeInterval(value, interval));
}));
});
}
export class TimeInterval {
constructor(value, interval) {
this.value = value;
this.interval = interval;
}
}
//# sourceMappingURL=timeInterval.js.map