UNPKG

assertthat

Version:
26 lines (25 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.prettyPrintObject = void 0; const formatNestedArray_1 = require("../utils/formatNestedArray"); const maximumFormattingDepth_1 = require("../../constants/maximumFormattingDepth"); const prepareSimple_1 = require("../utils/prepareSimple"); const prettyPrint_1 = require("../typeAware/prettyPrint"); const prettyPrintObject = function (object, depth = 0) { if (Object.keys(object).length === 0) { return '{}'; } const content = []; for (const [key, value] of Object.entries(object)) { content.push((0, prepareSimple_1.prepareSimple)(`${key}: ${(0, prettyPrint_1.prettyPrint)(value, depth + 1)}`, depth)); } if (depth >= maximumFormattingDepth_1.maximumFormattingDepth) { return (0, formatNestedArray_1.formatNestedArray) `{ ${content} }`; } return (0, formatNestedArray_1.formatNestedArray) ` { ${content} } `; }; exports.prettyPrintObject = prettyPrintObject;