diff options
Diffstat (limited to 'lib/internal/timers.js')
-rw-r--r-- | lib/internal/timers.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 4067c2ee0b..e55e17b537 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -72,7 +72,11 @@ // timers within (or creation of a new list). However, these operations combined // have shown to be trivial in comparison to other timers architectures. -const { Math, Object } = primordials; +const { + MathMax, + MathTrunc, + ObjectCreate, +} = primordials; const { scheduleTimer, @@ -137,7 +141,7 @@ const timerListQueue = new PriorityQueue(compareTimersLists, setPosition); // // - key = time in milliseconds // - value = linked list -const timerListMap = Object.create(null); +const timerListMap = ObjectCreate(null); function initAsyncResource(resource, type) { const asyncId = resource[async_id_symbol] = newAsyncId(); @@ -308,7 +312,7 @@ function insert(item, refed, start) { return; // Truncate so that accuracy of sub-millisecond timers is not assumed. - msecs = Math.trunc(msecs); + msecs = MathTrunc(msecs); item._idleStart = start; @@ -490,7 +494,7 @@ function getTimerCallbacks(runNextTicks) { // Check if this loop iteration is too early for the next timer. // This happens if there are more timers scheduled for later in the list. if (diff < msecs) { - list.expiry = Math.max(timer._idleStart + msecs, now + 1); + list.expiry = MathMax(timer._idleStart + msecs, now + 1); list.id = timerListId++; timerListQueue.percolateDown(1); debug('%d list wait because diff is %d', msecs, diff); |