fix(content): Make sure startTime is an integer

Because:
- Some devices may report performance.timeOrigin as a float instead of an int

This Commit:
- Converts performance.timeOrigin value to to an int
This commit is contained in:
dschom 2023-07-19 09:57:18 -07:00
Родитель 5a8e032a05
Коммит a49354bd6a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F26AEE99174EE68B
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -5,17 +5,17 @@
class Timers {
init(options) {
if (!options || !options.performance) {
throw new Error('options.performance required')
throw new Error('options.performance required');
}
this.completed = {};
this.running = {};
this.performance = options.performance;
this.baseTime = options.performance.timeOrigin;
this.baseTime = parseInt(options.performance.timeOrigin);
}
start(name) {
var start = this.performance.now()
var start = this.performance.now();
if (typeof this.running[name] === 'number') {
throw new Error(name + ' timer already started');
}
@ -24,7 +24,7 @@ class Timers {
}
stop(name) {
var stop = this.performance.now()
var stop = this.performance.now();
if (typeof this.running[name] !== 'number') {
throw new Error(name + ' timer not started');