mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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>
This commit is contained in:
1 parent
e53f5afdbe
commit
d3e1c5864b
2 files changed
+9
-7
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
+7
-6
@@ -28,6 +28,7 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
DateNow,
|
||||
MathCeil,
|
||||
MathFloor,
|
||||
MathMax,
|
||||
@@ -438,7 +439,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;
|
||||
}
|
||||
@@ -451,7 +452,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);
|
||||
@@ -834,14 +835,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;
|
||||
@@ -1015,14 +1016,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;
|
||||
|
||||
Reference in new issue
Block a user