function formatNonEmptyObject()

in src/helpers/whatif.ts [726:758]


function formatNonEmptyObject(
  builder: ColorStringBuilder,
  value: Record<string, UnknownValue>,
  path: string = "",
  maxPathLength: number = 0,
  indentLevel: number = 0,
): void {
  const isRoot = !path;

  if (!path) {
    // Root object.
    builder.appendLine().appendLine();
    maxPathLength = getMaxPathLengthFromObject(value);
    indentLevel += 1;
  }

  for (const [childPath, childValue] of entries(value)) {
    const formattedChildPath = isRoot
      ? childPath
      : `${path}${Symbol.Dot}${childPath}`;
    formatJsonValue(
      builder,
      childValue,
      formattedChildPath,
      maxPathLength,
      indentLevel,
    );

    if (!isNonEmptyObject(childValue)) {
      builder.appendLine();
    }
  }
}