assertthat
Version:
assertthat provides fluent TDD.
26 lines (25 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.prettyPrintMap = 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 prettyPrintMap = function (map, depth = 0) {
if (map.size === 0) {
return 'Map({})';
}
const content = [];
for (const [key, value] of map) {
content.push((0, prepareSimple_1.prepareSimple)(`${(0, prettyPrint_1.prettyPrint)(key, Number.POSITIVE_INFINITY)}: ${(0, prettyPrint_1.prettyPrint)(value, depth + 1)}`, depth));
}
if (depth >= maximumFormattingDepth_1.maximumFormattingDepth) {
return (0, formatNestedArray_1.formatNestedArray) `Map({ ${content} })`;
}
return (0, formatNestedArray_1.formatNestedArray) `
Map({
${content}
})
`;
};
exports.prettyPrintMap = prettyPrintMap;