UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

24 lines (22 loc) 677 B
import { AsyncIterableX } from '../asynciterablex'; export class TimeIntervalAsyncIterable extends AsyncIterableX { constructor(source) { super(); this._source = source; } async *[Symbol.asyncIterator]() { let last = Date.now(); for await (const item of this._source) { const now = Date.now(); const span = now - last; last = now; yield { value: item, elapsed: span }; } } } export function timeInterval() { return function timeIntervalOperatorFunction(source) { return new TimeIntervalAsyncIterable(source); }; } //# sourceMappingURL=timeinterval.mjs.map