diff options
author | Tchoupinax <corentinfiloche@hotmail.fr> | 2019-11-27 21:38:49 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-30 13:13:21 +0100 |
commit | 0da6983cdad80dad8c1d4155b1bc887ce37d9c40 (patch) | |
tree | 1ef4c0b5b2cf3903ef1c5fd28f6b58add06c369a /lib | |
parent | 52a3e3560484ec3ad4479ef80d829f7c99d39e80 (diff) | |
download | android-node-v8-0da6983cdad80dad8c1d4155b1bc887ce37d9c40.tar.gz android-node-v8-0da6983cdad80dad8c1d4155b1bc887ce37d9c40.tar.bz2 android-node-v8-0da6983cdad80dad8c1d4155b1bc887ce37d9c40.zip |
lib: replace Date.now function by primordial DateNow
PR-URL: https://github.com/nodejs/node/pull/30689
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/fs/utils.js | 3 | ||||
-rw-r--r-- | lib/readline.js | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 4d7f0d6765..f785719265 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -2,6 +2,7 @@ const { ArrayIsArray, + DateNow, ObjectSetPrototypeOf, ReflectOwnKeys, } = primordials; @@ -487,7 +488,7 @@ function toUnixTimestamp(time, name = 'time') { } if (Number.isFinite(time)) { if (time < 0) { - return Date.now() / 1000; + return DateNow() / 1000; } return time; } diff --git a/lib/readline.js b/lib/readline.js index c29aabb82b..57c2d6aff3 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -28,6 +28,7 @@ 'use strict'; const { + DateNow, MathCeil, MathFloor, MathMax, @@ -442,7 +443,7 @@ Interface.prototype._normalWrite = function(b) { } let string = this._decoder.write(b); if (this._sawReturnAt && - Date.now() - this._sawReturnAt <= this.crlfDelay) { + DateNow() - this._sawReturnAt <= this.crlfDelay) { string = string.replace(/^\n/, ''); this._sawReturnAt = 0; } @@ -455,7 +456,7 @@ Interface.prototype._normalWrite = function(b) { this._line_buffer = null; } if (newPartContainsEnding) { - this._sawReturnAt = string.endsWith('\r') ? Date.now() : 0; + this._sawReturnAt = string.endsWith('\r') ? DateNow() : 0; // Got one or more newlines; process into "line" events const lines = string.split(lineEnding); @@ -838,14 +839,14 @@ function _ttyWriteDumb(s, key) { switch (key.name) { case 'return': // Carriage return, i.e. \r - this._sawReturnAt = Date.now(); + this._sawReturnAt = DateNow(); this._line(); break; case 'enter': // When key interval > crlfDelay if (this._sawReturnAt === 0 || - Date.now() - this._sawReturnAt > this.crlfDelay) { + DateNow() - this._sawReturnAt > this.crlfDelay) { this._line(); } this._sawReturnAt = 0; @@ -1019,14 +1020,14 @@ Interface.prototype._ttyWrite = function(s, key) { switch (key.name) { case 'return': // Carriage return, i.e. \r - this._sawReturnAt = Date.now(); + this._sawReturnAt = DateNow(); this._line(); break; case 'enter': // When key interval > crlfDelay if (this._sawReturnAt === 0 || - Date.now() - this._sawReturnAt > this.crlfDelay) { + DateNow() - this._sawReturnAt > this.crlfDelay) { this._line(); } this._sawReturnAt = 0; |