improve indentation when displaying objects with console.log
@@ -124,23 +124,19 @@ function createIterableString<T>(
const iPrefix = `${config.displayName ? config.displayName + " " : ""}`;
- let iContent: string;
- if (config.group && entries.length > MIN_GROUP_LENGTH) {
- const groups = groupEntries(entries, level, value);
const initIndentation = `\n${DEFAULT_INDENT.repeat(level + 1)}`;
const entryIndentation = `,\n${DEFAULT_INDENT.repeat(level + 1)}`;
const closingIndentation = `\n${DEFAULT_INDENT.repeat(level)}`;
+ let iContent: string;
+ if (config.group && entries.length > MIN_GROUP_LENGTH) {
+ const groups = groupEntries(entries, level, value);
iContent = `${initIndentation}${groups.join(
entryIndentation
)}${closingIndentation}`;
} else {
iContent = entries.length === 0 ? "" : ` ${entries.join(", ")} `;
if (stripColor(iContent).length > LINE_BREAKING_LENGTH) {
- const initIndentation = `\n${DEFAULT_INDENT.repeat(level + 1)}`;
- const entryIndentation = `,\n${DEFAULT_INDENT.repeat(level + 1)}`;
- const closingIndentation = `\n`;
-
iContent = `${initIndentation}${entries.join(
entryIndentation
)}${closingIndentation}`;
@@ -343,7 +339,7 @@ function createArrayString(
const ending = emptyItems > 1 ? "s" : "";
return dim(`<${emptyItems} empty item${ending}>`);
} else {
- return stringifyWithQuotes(val, ctx, level + 1, maxLevel);
+ return stringifyWithQuotes(val, ctx, level, maxLevel);
}
},
group: true,
