From ddbfa1418c5ec2805a565caa07f7eec6af1deb39 Mon Sep 17 00:00:00 2001 From: Ben Heidemann <56122437+bcheidemann@users.noreply.github.com> Date: Mon, 25 Apr 2022 12:59:15 +0100 Subject: feat(ext/console): Add string abbreviation size option for "Deno.inspect" (#14384) --- ext/console/02_console.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ext/console/02_console.js') 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 } -- cgit v1.2.3