1
0
Fork 0
react-playground/node_modules/@mui/x-internals/warning/warning.js
Techognito fc0f69dacb Added Statistics calculation
Statistics now show calculated values
2025-09-04 17:30:00 +02:00

37 lines
No EOL
1,013 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.clearWarningsCache = clearWarningsCache;
exports.warnOnce = warnOnce;
const warnedOnceCache = new Set();
/**
* Logs a message to the console on development mode. The warning will only be logged once.
*
* The message is the log's cache key. Two identical messages will only be logged once.
*
* This function is a no-op in production.
*
* @param message the message to log
* @param gravity the gravity of the warning. Defaults to `'warning'`.
* @returns
*/
function warnOnce(message, gravity = 'warning') {
if (process.env.NODE_ENV === 'production') {
return;
}
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
if (!warnedOnceCache.has(cleanMessage)) {
warnedOnceCache.add(cleanMessage);
if (gravity === 'error') {
console.error(cleanMessage);
} else {
console.warn(cleanMessage);
}
}
}
function clearWarningsCache() {
warnedOnceCache.clear();
}