timing-provider
Version:
An implementation of the timing provider specification.
12 lines • 758 B
JavaScript
import { filter, map, withLatestFrom } from 'rxjs';
import { isNotNullish } from 'rxjs-etc';
export const matchPongWithPing = (localSentTimesSubject) => (source) => source.pipe(withLatestFrom(localSentTimesSubject), map(([{ index, remoteReceivedTime, remoteSentTime, timestamp }, [startIndex, localSentTimes]]) => {
if (index < startIndex) {
return null;
}
const numberOfMissingPings = index - startIndex;
const [localSentTime, ...unansweredPings] = localSentTimes.slice(numberOfMissingPings);
localSentTimesSubject.next([startIndex + numberOfMissingPings + 1, unansweredPings]);
return [localSentTime, remoteReceivedTime, remoteSentTime, timestamp];
}), filter(isNotNullish));
//# sourceMappingURL=match-pong-with-ping.js.map