LordXido commited on
Commit
29e7b23
·
verified ·
1 Parent(s): 4648f7d

Create plme.js

Browse files
Files changed (1) hide show
  1. plme.js +16 -0
plme.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(callback) {
10
+ replaying = true;
11
+ startTime = performance.now();
12
+
13
+ timeline.forEach(pkt => {
14
+ setTimeout(() => callback(pkt), pkt.timestamp - timeline[0].timestamp);
15
+ });
16
+ }