Spaces:
Running
Running
File size: 261 Bytes
29e7b23 ed4ca56 29e7b23 ed4ca56 29e7b23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | const timeline = [];
export function record(packet) {
timeline.push(packet);
}
export function replay(cb) {
if (!timeline.length) return;
const t0 = timeline[0].timestamp;
timeline.forEach(p => {
setTimeout(() => cb(p), p.timestamp - t0);
});
} |