Spaces:
Running
Running
Update plme.js
Browse files
plme.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
| 1 |
const timeline = [];
|
| 2 |
-
let replaying = false;
|
| 3 |
-
let startTime = 0;
|
| 4 |
|
| 5 |
export function record(packet) {
|
| 6 |
timeline.push(packet);
|
| 7 |
}
|
| 8 |
|
| 9 |
-
export function replay(
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
timeline.forEach(
|
| 14 |
-
setTimeout(() =>
|
| 15 |
});
|
| 16 |
}
|
|
|
|
| 1 |
const timeline = [];
|
|
|
|
|
|
|
| 2 |
|
| 3 |
export function record(packet) {
|
| 4 |
timeline.push(packet);
|
| 5 |
}
|
| 6 |
|
| 7 |
+
export function replay(cb) {
|
| 8 |
+
if (!timeline.length) return;
|
| 9 |
+
const t0 = timeline[0].timestamp;
|
| 10 |
|
| 11 |
+
timeline.forEach(p => {
|
| 12 |
+
setTimeout(() => cb(p), p.timestamp - t0);
|
| 13 |
});
|
| 14 |
}
|