@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
30 lines (28 loc) • 851 B
JavaScript
/**
* Formats unknown values safely for logs (avoids "[object Object]" and circular JSON issues).
* @param {unknown} value - Value to format
* @returns {string} String representation suitable for logs
*/
function FormatUnknownForLog(value) {
if (typeof value === "string") {
return value;
}
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
return String(value);
}
if (value === null) {
return "null";
}
if (value === undefined) {
return "undefined";
}
try {
const json = JSON.stringify(value);
return json ?? Object.prototype.toString.call(value);
}
catch {
return Object.prototype.toString.call(value);
}
}
export { FormatUnknownForLog };
//# sourceMappingURL=format-unknown-for-log.utility.js.map