util: remove eslint comments and rename variables
This should improve the readability of the code. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
1bee544a20
commit
6cc74b038f
@ -822,12 +822,11 @@ function formatPrimitive(fn, value, ctx) {
|
|||||||
if (ctx.compact === false &&
|
if (ctx.compact === false &&
|
||||||
ctx.indentationLvl + value.length > ctx.breakLength &&
|
ctx.indentationLvl + value.length > ctx.breakLength &&
|
||||||
value.length > kMinLineLength) {
|
value.length > kMinLineLength) {
|
||||||
// eslint-disable-next-line max-len
|
const rawMaxLineLength = ctx.breakLength - ctx.indentationLvl;
|
||||||
const minLineLength = Math.max(ctx.breakLength - ctx.indentationLvl, kMinLineLength);
|
const maxLineLength = Math.max(rawMaxLineLength, kMinLineLength);
|
||||||
// eslint-disable-next-line max-len
|
const lines = Math.ceil(value.length / maxLineLength);
|
||||||
const averageLineLength = Math.ceil(value.length / Math.ceil(value.length / minLineLength));
|
const averageLineLength = Math.ceil(value.length / lines);
|
||||||
const divisor = Math.max(averageLineLength, kMinLineLength);
|
const divisor = Math.max(averageLineLength, kMinLineLength);
|
||||||
let res = '';
|
|
||||||
if (readableRegExps[divisor] === undefined) {
|
if (readableRegExps[divisor] === undefined) {
|
||||||
// Build a new RegExp that naturally breaks text into multiple lines.
|
// Build a new RegExp that naturally breaks text into multiple lines.
|
||||||
//
|
//
|
||||||
@ -843,7 +842,7 @@ function formatPrimitive(fn, value, ctx) {
|
|||||||
const matches = value.match(readableRegExps[divisor]);
|
const matches = value.match(readableRegExps[divisor]);
|
||||||
if (matches.length > 1) {
|
if (matches.length > 1) {
|
||||||
const indent = ' '.repeat(ctx.indentationLvl);
|
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++) {
|
for (var i = 1; i < matches.length - 1; i++) {
|
||||||
res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`;
|
res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user