UNPKG

@antdv/pro-utils

Version:

@antdv/pro-utils

76 lines (75 loc) 2.35 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var stdin_exports = {}; __export(stdin_exports, { call: () => call, default: () => stdin_default, note: () => note, noteOnce: () => noteOnce, preMessage: () => preMessage, resetWarned: () => resetWarned, warning: () => warning, warningOnce: () => warningOnce }); module.exports = __toCommonJS(stdin_exports); let warned = {}; const preWarningFns = []; function preMessage(fn) { preWarningFns.push(fn); } function warning(valid, message) { if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) { const finalMessage = preWarningFns.reduce( (msg, preMessageFn) => preMessageFn(msg != null ? msg : "", "warning"), message ); if (finalMessage) { console.error(`Warning: ${finalMessage}`); } } } function note(valid, message) { if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) { const finalMessage = preWarningFns.reduce( (msg, preMessageFn) => preMessageFn(msg != null ? msg : "", "note"), message ); if (finalMessage) { console.warn(`Note: ${finalMessage}`); } } } function resetWarned() { warned = {}; } function call(method, valid, message) { if (!valid && !warned[message]) { method(false, message); warned[message] = true; } } function warningOnce(valid, message) { call(warning, valid, message); } function noteOnce(valid, message) { call(note, valid, message); } warningOnce.preMessage = preMessage; warningOnce.resetWarned = resetWarned; warningOnce.noteOnce = noteOnce; var stdin_default = warningOnce;