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