diff options
author | Ben Heidemann <56122437+bcheidemann@users.noreply.github.com> | 2022-04-25 12:59:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 13:59:15 +0200 |
commit | ddbfa1418c5ec2805a565caa07f7eec6af1deb39 (patch) | |
tree | 26daa26b991a0e3a465205380af22b73cb89c973 /ext/console/02_console.js | |
parent | 6dcf3a447c688130d79751ad7e6e508631f7032d (diff) |
feat(ext/console): Add string abbreviation size option for "Deno.inspect" (#14384)
Diffstat (limited to 'ext/console/02_console.js')
-rw-r--r-- | ext/console/02_console.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 0f51bded8..607da2db6 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -298,6 +298,7 @@ colors: false, getters: false, showHidden: false, + strAbbreviateSize: 100, }; const DEFAULT_INDENT = " "; // Default indent string @@ -786,11 +787,15 @@ level, inspectOptions, ) { + const abbreviateSize = + typeof inspectOptions.strAbbreviateSize === "undefined" + ? STR_ABBREVIATE_SIZE + : inspectOptions.strAbbreviateSize; const green = maybeColor(colors.green, inspectOptions); switch (typeof value) { case "string": { - const trunc = value.length > STR_ABBREVIATE_SIZE - ? StringPrototypeSlice(value, 0, STR_ABBREVIATE_SIZE) + "..." + const trunc = value.length > abbreviateSize + ? StringPrototypeSlice(value, 0, abbreviateSize) + "..." : value; return green(quoteString(trunc)); // Quoted strings are green } |