Files
med-notes/.pnpm-store/v10/files/4d/2270e43b4eae307551a1b77b724d4a5425b90e55d78d18853e8b228dd4c1f5e1b1cca8cfbcec56db79e369ecab0fda6950697654a34e69c48b0b6f4fe061e2
2025-05-09 05:30:08 +02:00

24 lines
546 B
Plaintext

/**
* @fileoverview Shared utilities for error messages.
* @author Josh Goldberg
*/
"use strict";
/**
* Converts a value to a string that may be printed in errors.
* @param {any} value The invalid value.
* @param {number} indentation How many spaces to indent
* @returns {string} The value, stringified.
*/
function stringifyValueForError(value, indentation) {
return value
? JSON.stringify(value, null, 4).replace(
/\n/gu,
`\n${" ".repeat(indentation)}`,
)
: `${value}`;
}
module.exports = { stringifyValueForError };