Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
util: remove eslint comments and rename variables
This should improve the readability of the code.
  • Loading branch information
BridgeAR committed Dec 28, 2018
commit 669c2f4cc207cad87c4fb7143e746298802d46bf
11 changes: 5 additions & 6 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,11 @@ function formatPrimitive(fn, value, ctx) {
if (ctx.compact === false &&
ctx.indentationLvl + value.length > ctx.breakLength &&
value.length > kMinLineLength) {
// eslint-disable-next-line max-len
const minLineLength = Math.max(ctx.breakLength - ctx.indentationLvl, kMinLineLength);
// eslint-disable-next-line max-len
const averageLineLength = Math.ceil(value.length / Math.ceil(value.length / minLineLength));
const rawMaxLineLength = ctx.breakLength - ctx.indentationLvl;
const maxLineLength = Math.max(rawMaxLineLength, kMinLineLength);
const lines = Math.ceil(value.length / maxLineLength);
const averageLineLength = Math.ceil(value.length / lines);
const divisor = Math.max(averageLineLength, kMinLineLength);
let res = '';
if (readableRegExps[divisor] === undefined) {
// Build a new RegExp that naturally breaks text into multiple lines.
//
Expand All @@ -832,7 +831,7 @@ function formatPrimitive(fn, value, ctx) {
const matches = value.match(readableRegExps[divisor]);
if (matches.length > 1) {
const indent = ' '.repeat(ctx.indentationLvl);
res += `${fn(strEscape(matches[0]), 'string')} +\n`;
let res = `${fn(strEscape(matches[0]), 'string')} +\n`;
for (var i = 1; i < matches.length - 1; i++) {
res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`;
}
Expand Down