timers: use const as appropriate
PR-URL: https://github.com/nodejs/node/pull/18486 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
a986158cbf
commit
71c0d0370a
@ -224,8 +224,8 @@ function TimersList(msecs, unrefed) {
|
|||||||
// adds listOnTimeout to the C++ object prototype, as
|
// adds listOnTimeout to the C++ object prototype, as
|
||||||
// V8 would not inline it otherwise.
|
// V8 would not inline it otherwise.
|
||||||
TimerWrap.prototype[kOnTimeout] = function listOnTimeout(now) {
|
TimerWrap.prototype[kOnTimeout] = function listOnTimeout(now) {
|
||||||
var list = this._list;
|
const list = this._list;
|
||||||
var msecs = list.msecs;
|
const msecs = list.msecs;
|
||||||
|
|
||||||
debug('timeout callback %d', msecs);
|
debug('timeout callback %d', msecs);
|
||||||
debug('now: %d', now);
|
debug('now: %d', now);
|
||||||
@ -322,7 +322,7 @@ function tryOnTimeout(timer, list) {
|
|||||||
function reuse(item) {
|
function reuse(item) {
|
||||||
L.remove(item);
|
L.remove(item);
|
||||||
|
|
||||||
var list = refedLists[item._idleTimeout];
|
const list = refedLists[item._idleTimeout];
|
||||||
// if empty - reuse the watcher
|
// if empty - reuse the watcher
|
||||||
if (list !== undefined && L.isEmpty(list)) {
|
if (list !== undefined && L.isEmpty(list)) {
|
||||||
debug('reuse hit');
|
debug('reuse hit');
|
||||||
@ -346,7 +346,7 @@ function unenroll(item) {
|
|||||||
item._destroyed = true;
|
item._destroyed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var handle = reuse(item);
|
const handle = reuse(item);
|
||||||
if (handle !== null) {
|
if (handle !== null) {
|
||||||
debug('unenroll: list empty');
|
debug('unenroll: list empty');
|
||||||
handle.close();
|
handle.close();
|
||||||
@ -429,7 +429,7 @@ exports.setTimeout = setTimeout;
|
|||||||
|
|
||||||
|
|
||||||
function ontimeout(timer, start) {
|
function ontimeout(timer, start) {
|
||||||
var args = timer._timerArgs;
|
const args = timer._timerArgs;
|
||||||
if (typeof timer._onTimeout !== 'function')
|
if (typeof timer._onTimeout !== 'function')
|
||||||
return promiseResolve(timer._onTimeout, args[0]);
|
return promiseResolve(timer._onTimeout, args[0]);
|
||||||
if (start === undefined && timer._repeat)
|
if (start === undefined && timer._repeat)
|
||||||
@ -540,7 +540,7 @@ Timeout.prototype.unref = function() {
|
|||||||
if (this._handle) {
|
if (this._handle) {
|
||||||
this._handle.unref();
|
this._handle.unref();
|
||||||
} else if (typeof this._onTimeout === 'function') {
|
} else if (typeof this._onTimeout === 'function') {
|
||||||
var now = TimerWrap.now();
|
const now = TimerWrap.now();
|
||||||
if (!this._idleStart) this._idleStart = now;
|
if (!this._idleStart) this._idleStart = now;
|
||||||
var delay = this._idleStart + this._idleTimeout - now;
|
var delay = this._idleStart + this._idleTimeout - now;
|
||||||
if (delay < 0) delay = 0;
|
if (delay < 0) delay = 0;
|
||||||
@ -551,7 +551,7 @@ Timeout.prototype.unref = function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var handle = reuse(this);
|
const handle = reuse(this);
|
||||||
if (handle !== null) {
|
if (handle !== null) {
|
||||||
handle._list = undefined;
|
handle._list = undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user