| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -822,12 +822,11 @@ function formatPrimitive(fn, value, ctx) { | |||
| 822 | 822 | if (ctx.compact === false && | |
| 823 | 823 | ctx.indentationLvl + value.length > ctx.breakLength && | |
| 824 | 824 | value.length > kMinLineLength) { | |
| 825 | - // eslint-disable-next-line max-len | ||
| 826 | - const minLineLength = Math.max(ctx.breakLength - ctx.indentationLvl, kMinLineLength); | ||
| 827 | - // eslint-disable-next-line max-len | ||
| 828 | - const averageLineLength = Math.ceil(value.length / Math.ceil(value.length / minLineLength)); | ||
| 825 | + const rawMaxLineLength = ctx.breakLength - ctx.indentationLvl; | ||
| 826 | + const maxLineLength = Math.max(rawMaxLineLength, kMinLineLength); | ||
| 827 | + const lines = Math.ceil(value.length / maxLineLength); | ||
| 828 | + const averageLineLength = Math.ceil(value.length / lines); | ||
| 829 | 829 | const divisor = Math.max(averageLineLength, kMinLineLength); | |
| 830 | - let res = ''; | ||
| 831 | 830 | if (readableRegExps[divisor] === undefined) { | |
| 832 | 831 | // Build a new RegExp that naturally breaks text into multiple lines. | |
| 833 | 832 | // | |
@@ -843,7 +842,7 @@ function formatPrimitive(fn, value, ctx) { | |||
| 843 | 842 | const matches = value.match(readableRegExps[divisor]); | |
| 844 | 843 | if (matches.length > 1) { | |
| 845 | 844 | const indent = ' '.repeat(ctx.indentationLvl); | |
| 846 | - res += `${fn(strEscape(matches[0]), 'string')} +\n`; | ||
| 845 | + let res = `${fn(strEscape(matches[0]), 'string')} +\n`; | ||
| 847 | 846 | for (var i = 1; i < matches.length - 1; i++) { | |
| 848 | 847 | res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`; | |
| 849 | 848 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments