ant-design-vue/components/_util/warning.js

39 lines
831 B
JavaScript
Raw Normal View History

2019-08-28 14:56:51 +00:00
/* eslint-disable no-console */
let warned = {};
2017-12-07 10:33:33 +00:00
2019-08-28 14:56:51 +00:00
export function warning(valid, message) {
// Support uglify
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
console.error(`Warning: ${message}`);
}
}
export function note(valid, message) {
// Support uglify
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
console.warn(`Note: ${message}`);
}
}
export function resetWarned() {
warned = {};
}
2019-08-29 14:50:53 +00:00
export function call(method, valid, message) {
2018-01-16 11:15:07 +00:00
if (!valid && !warned[message]) {
2019-08-28 14:56:51 +00:00
method(false, message);
2019-01-12 03:33:27 +00:00
warned[message] = true;
2017-12-07 10:33:33 +00:00
}
2019-08-28 14:56:51 +00:00
}
export function warningOnce(valid, message) {
call(warning, valid, message);
}
export function noteOnce(valid, message) {
call(note, valid, message);
}
export default warningOnce;
/* eslint-enable */