@oscarpalmer/timer 0.38.0 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,20 +63,6 @@ document.addEventListener("visibilitychange", () => {
|
|
|
63
63
|
from.clear();
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
var typeArrays = new Set([
|
|
67
|
-
Int8Array,
|
|
68
|
-
Uint8Array,
|
|
69
|
-
Uint8ClampedArray,
|
|
70
|
-
Int16Array,
|
|
71
|
-
Uint16Array,
|
|
72
|
-
Int32Array,
|
|
73
|
-
Uint32Array,
|
|
74
|
-
Float32Array,
|
|
75
|
-
Float64Array,
|
|
76
|
-
BigInt64Array,
|
|
77
|
-
BigUint64Array
|
|
78
|
-
]);
|
|
79
|
-
|
|
80
66
|
function calculate() {
|
|
81
67
|
return new Promise((resolve) => {
|
|
82
68
|
const values = [];
|
|
@@ -84,18 +70,34 @@ function calculate() {
|
|
|
84
70
|
function step(now) {
|
|
85
71
|
if (last != null) values.push(now - last);
|
|
86
72
|
last = now;
|
|
87
|
-
if (values.length >=
|
|
73
|
+
if (values.length >= CALCULATION_TOTAL) resolve(values.sort().slice(2, -2).reduce((first, second) => first + second, 0) / (values.length - CALCULATION_TRIM));
|
|
88
74
|
else requestAnimationFrame(step);
|
|
89
75
|
}
|
|
90
76
|
requestAnimationFrame(step);
|
|
91
77
|
});
|
|
92
78
|
}
|
|
93
79
|
function noop() {}
|
|
80
|
+
var CALCULATION_TOTAL = 10;
|
|
81
|
+
var CALCULATION_TRIM = 4;
|
|
94
82
|
let milliseconds = 1e3 / 60;
|
|
95
83
|
calculate().then((value) => {
|
|
96
84
|
milliseconds = value;
|
|
97
85
|
});
|
|
98
86
|
|
|
87
|
+
var TYPED_ARRAYS = new Set([
|
|
88
|
+
Int8Array,
|
|
89
|
+
Uint8Array,
|
|
90
|
+
Uint8ClampedArray,
|
|
91
|
+
Int16Array,
|
|
92
|
+
Uint16Array,
|
|
93
|
+
Int32Array,
|
|
94
|
+
Uint32Array,
|
|
95
|
+
Float32Array,
|
|
96
|
+
Float64Array,
|
|
97
|
+
BigInt64Array,
|
|
98
|
+
BigUint64Array
|
|
99
|
+
]);
|
|
100
|
+
|
|
99
101
|
function getCallback(value) {
|
|
100
102
|
return typeof value === "function" ? value : noop;
|
|
101
103
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://oscarpalmer.se"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@oscarpalmer/atoms": "^0.
|
|
7
|
+
"@oscarpalmer/atoms": "^0.115"
|
|
8
8
|
},
|
|
9
9
|
"description": "A better solution for timeout- and interval-based timers.",
|
|
10
10
|
"devDependencies": {
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
},
|
|
71
71
|
"type": "module",
|
|
72
72
|
"types": "types/index.d.ts",
|
|
73
|
-
"version": "0.38.
|
|
73
|
+
"version": "0.38.1"
|
|
74
74
|
}
|