UNPKG

assertthat

Version:
35 lines (34 loc) 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.prettyPrintSetDiff = void 0; const formatNestedArray_1 = require("../utils/formatNestedArray"); const maximumFormattingDepth_1 = require("../../constants/maximumFormattingDepth"); const prepareAddition_1 = require("../utils/prepareAddition"); const prepareOmission_1 = require("../utils/prepareOmission"); const prepareSimple_1 = require("../utils/prepareSimple"); const prettyPrint_1 = require("../typeAware/prettyPrint"); const propagateDiffSymbols_1 = require("../utils/propagateDiffSymbols"); const prettyPrintSetDiff = function (diff, depth = 0) { const content = []; for (const value of diff.equal) { content.push((0, prepareSimple_1.prepareSimple)((0, prettyPrint_1.prettyPrint)(value, depth + 1), depth)); } for (const value of diff.omissions) { content.push((0, prepareOmission_1.prepareOmission)((0, prettyPrint_1.prettyPrint)(value, depth + 1), depth)); } for (const value of diff.additions) { content.push((0, prepareAddition_1.prepareAddition)((0, prettyPrint_1.prettyPrint)(value, depth + 1), depth)); } if (content.length === 0) { return `Set([])`; } if (depth >= maximumFormattingDepth_1.maximumFormattingDepth) { return (0, formatNestedArray_1.formatNestedArray) `Set([ ${content} ])`; } return (0, propagateDiffSymbols_1.propagateDiffSymbols)((0, formatNestedArray_1.formatNestedArray) ` Set([ ${content} ]) `); }; exports.prettyPrintSetDiff = prettyPrintSetDiff;