17 lines
375 B
JavaScript
17 lines
375 B
JavaScript
export const suppressWarnings = warnings => {
|
|
if (!warnings?.length) {
|
|
return
|
|
}
|
|
const regex = new RegExp(warnings.map(x => `(${x})`).join("|"), "gi")
|
|
const warn = console.warn
|
|
console.warn = (...params) => {
|
|
const msg = params[0]
|
|
if (msg && typeof msg === "string") {
|
|
if (msg.match(regex)) {
|
|
return
|
|
}
|
|
}
|
|
warn(...params)
|
|
}
|
|
}
|