diff options
author | Ben Heidemann <56122437+bcheidemann@users.noreply.github.com> | 2022-04-26 12:04:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 13:04:28 +0200 |
commit | dc4ab1d9340a58f81beab24ef211e900acbb9ad8 (patch) | |
tree | ee341f04c26976129c113096a71ca49290b9a694 /ext | |
parent | e24b8f075ead5ceab192eed67caaa9f3ba0fbfa4 (diff) |
feat(ext/console): Compact empty iterables when calling Deno.inspect with compact false (#14387)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/console/02_console.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 607da2db6..9b54a64a1 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -465,12 +465,18 @@ const entryIndentation = `,\n${ StringPrototypeRepeat(DEFAULT_INDENT, level + 1) }`; - const closingIndentation = `${inspectOptions.trailingComma ? "," : ""}\n${ - StringPrototypeRepeat(DEFAULT_INDENT, level) - }`; + const closingDelimIndentation = StringPrototypeRepeat( + DEFAULT_INDENT, + level, + ); + const closingIndentation = `${ + inspectOptions.trailingComma ? "," : "" + }\n${closingDelimIndentation}`; let iContent; - if (options.group && entries.length > MIN_GROUP_LENGTH) { + if (entries.length === 0 && !inspectOptions.compact) { + iContent = `\n${closingDelimIndentation}`; + } else if (options.group && entries.length > MIN_GROUP_LENGTH) { const groups = groupEntries(entries, level, value); iContent = `${initIndentation}${ ArrayPrototypeJoin(groups, entryIndentation) |