diff options
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/readline.js b/lib/readline.js index 13c70fbb8c..c29aabb82b 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -27,7 +27,13 @@ 'use strict'; -const { Math, Object } = primordials; +const { + MathCeil, + MathFloor, + MathMax, + ObjectDefineProperty, + ObjectSetPrototypeOf, +} = primordials; const { ERR_INVALID_CALLBACK, @@ -150,7 +156,7 @@ function Interface(input, output, completer, terminal) { this.historySize = historySize; this.removeHistoryDuplicates = !!removeHistoryDuplicates; this.crlfDelay = crlfDelay ? - Math.max(kMincrlfDelay, crlfDelay) : kMincrlfDelay; + MathMax(kMincrlfDelay, crlfDelay) : kMincrlfDelay; // Check arity, 2 - for async, 1 for sync if (typeof completer === 'function') { this.completer = completer.length === 2 ? @@ -251,10 +257,10 @@ function Interface(input, output, completer, terminal) { input.resume(); } -Object.setPrototypeOf(Interface.prototype, EventEmitter.prototype); -Object.setPrototypeOf(Interface, EventEmitter); +ObjectSetPrototypeOf(Interface.prototype, EventEmitter.prototype); +ObjectSetPrototypeOf(Interface, EventEmitter); -Object.defineProperty(Interface.prototype, 'columns', { +ObjectDefineProperty(Interface.prototype, 'columns', { configurable: true, enumerable: true, get: function() { @@ -507,7 +513,7 @@ Interface.prototype._tabComplete = function(lastKeypressWasTab) { const width = completions.reduce(function completionReducer(a, b) { return a.length > b.length ? a : b; }).length + 2; // 2 space padding - let maxColumns = Math.floor(self.columns / width); + let maxColumns = MathFloor(self.columns / width); if (!maxColumns || maxColumns === Infinity) { maxColumns = 1; } @@ -541,7 +547,7 @@ function handleGroup(self, group, width, maxColumns) { if (group.length === 0) { return; } - const minRows = Math.ceil(group.length / maxColumns); + const minRows = MathCeil(group.length / maxColumns); for (let row = 0; row < minRows; row++) { for (let col = 0; col < maxColumns; col++) { const idx = row * maxColumns + col; @@ -733,7 +739,7 @@ Interface.prototype._getDisplayPos = function(str) { } if (code === 0x0a) { // new line \n // row must be incremented by 1 even if offset = 0 or col = +Infinity - row += Math.ceil(offset / col) || 1; + row += MathCeil(offset / col) || 1; offset = 0; continue; } |