UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

123 lines (102 loc) 3.4 kB
import _unset from "lodash/unset"; import _set from "lodash/set"; import _has from "lodash/has"; import _noop from "lodash/noop"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } export var isDevMode = function isReactInDev() { // This property gets injected via Webpack. return process.env.NODE_ENV !== 'production'; // eslint-disable-line no-undef }(); export var isNode = (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process.title === 'node'; export var logger = function () { return checkIsDev() ? { log: log, logOnce: logOnce, warn: warn, warnOnce: warnOnce, error: error, errorOnce: errorOnce, resetOnce: resetOnce } : { log: _noop, logOnce: _noop, warn: _noop, warnOnce: _noop, error: _noop, errorOnce: _noop, resetOnce: _noop }; }(); var onceMap = {}; function once(key, fn) { if (!_has(onceMap, key)) { _set(onceMap, key, true); fn(); } } function resetOnce(key) { _unset(onceMap, key); } export function checkIsDev() { return isDevMode && typeof window !== 'undefined' && typeof console !== 'undefined'; } function log() { var _console; (_console = console).log.apply(_console, arguments); try { // --- Welcome to debugging Lucid --- // This error was thrown as a convenience so that you can use this // stack to find the callsite that caused this warning to fire. throw new Error(arguments.length <= 0 ? undefined : arguments[0]); } catch (x) { /* */ } } function logOnce(key) { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } once(key, function () { return log.apply(void 0, args); }); } function warn() { var _console2; (_console2 = console).warn.apply(_console2, arguments); try { // --- Welcome to debugging Lucid --- // This error was thrown as a convenience so that you can use this // stack to find the callsite that caused this warning to fire. throw new Error(arguments.length <= 0 ? undefined : arguments[0]); } catch (x) { /* */ } } function warnOnce(key) { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } once(key, function () { return warn.apply(void 0, args); }); } function error() { var _console3; (_console3 = console).error.apply(_console3, arguments); try { // --- Welcome to debugging Lucid --- // This error was thrown as a convenience so that you can use this // stack to find the callsite that caused this warning to fire. throw new Error(arguments.length <= 0 ? undefined : arguments[0]); } catch (x) { /* */ } } function errorOnce(key) { for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { args[_key3 - 1] = arguments[_key3]; } once(key, function () { return error.apply(void 0, args); }); }