debug.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. "use strict";
  2. function _typeof(obj) { 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); }
  3. (function (f) {
  4. if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
  5. module.exports = f();
  6. } else if (typeof define === "function" && define.amd) {
  7. define([], f);
  8. } else {
  9. var g;
  10. if (typeof window !== "undefined") {
  11. g = window;
  12. } else if (typeof global !== "undefined") {
  13. g = global;
  14. } else if (typeof self !== "undefined") {
  15. g = self;
  16. } else {
  17. g = this;
  18. }
  19. g.debug = f();
  20. }
  21. })(function () {
  22. var define, module, exports;
  23. return function () {
  24. function r(e, n, t) {
  25. function o(i, f) {
  26. if (!n[i]) {
  27. if (!e[i]) {
  28. var c = "function" == typeof require && require;
  29. if (!f && c) return c(i, !0);
  30. if (u) return u(i, !0);
  31. var a = new Error("Cannot find module '" + i + "'");
  32. throw a.code = "MODULE_NOT_FOUND", a;
  33. }
  34. var p = n[i] = {
  35. exports: {}
  36. };
  37. e[i][0].call(p.exports, function (r) {
  38. var n = e[i][1][r];
  39. return o(n || r);
  40. }, p, p.exports, r, e, n, t);
  41. }
  42. return n[i].exports;
  43. }
  44. for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
  45. o(t[i]);
  46. }
  47. return o;
  48. }
  49. return r;
  50. }()({
  51. 1: [function (require, module, exports) {
  52. /**
  53. * Helpers.
  54. */
  55. var s = 1000;
  56. var m = s * 60;
  57. var h = m * 60;
  58. var d = h * 24;
  59. var w = d * 7;
  60. var y = d * 365.25;
  61. /**
  62. * Parse or format the given `val`.
  63. *
  64. * Options:
  65. *
  66. * - `long` verbose formatting [false]
  67. *
  68. * @param {String|Number} val
  69. * @param {Object} [options]
  70. * @throws {Error} throw an error if val is not a non-empty string or a number
  71. * @return {String|Number}
  72. * @api public
  73. */
  74. module.exports = function (val, options) {
  75. options = options || {};
  76. var type = _typeof(val);
  77. if (type === 'string' && val.length > 0) {
  78. return parse(val);
  79. } else if (type === 'number' && isNaN(val) === false) {
  80. return options.long ? fmtLong(val) : fmtShort(val);
  81. }
  82. throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
  83. };
  84. /**
  85. * Parse the given `str` and return milliseconds.
  86. *
  87. * @param {String} str
  88. * @return {Number}
  89. * @api private
  90. */
  91. function parse(str) {
  92. str = String(str);
  93. if (str.length > 100) {
  94. return;
  95. }
  96. var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
  97. if (!match) {
  98. return;
  99. }
  100. var n = parseFloat(match[1]);
  101. var type = (match[2] || 'ms').toLowerCase();
  102. switch (type) {
  103. case 'years':
  104. case 'year':
  105. case 'yrs':
  106. case 'yr':
  107. case 'y':
  108. return n * y;
  109. case 'weeks':
  110. case 'week':
  111. case 'w':
  112. return n * w;
  113. case 'days':
  114. case 'day':
  115. case 'd':
  116. return n * d;
  117. case 'hours':
  118. case 'hour':
  119. case 'hrs':
  120. case 'hr':
  121. case 'h':
  122. return n * h;
  123. case 'minutes':
  124. case 'minute':
  125. case 'mins':
  126. case 'min':
  127. case 'm':
  128. return n * m;
  129. case 'seconds':
  130. case 'second':
  131. case 'secs':
  132. case 'sec':
  133. case 's':
  134. return n * s;
  135. case 'milliseconds':
  136. case 'millisecond':
  137. case 'msecs':
  138. case 'msec':
  139. case 'ms':
  140. return n;
  141. default:
  142. return undefined;
  143. }
  144. }
  145. /**
  146. * Short format for `ms`.
  147. *
  148. * @param {Number} ms
  149. * @return {String}
  150. * @api private
  151. */
  152. function fmtShort(ms) {
  153. var msAbs = Math.abs(ms);
  154. if (msAbs >= d) {
  155. return Math.round(ms / d) + 'd';
  156. }
  157. if (msAbs >= h) {
  158. return Math.round(ms / h) + 'h';
  159. }
  160. if (msAbs >= m) {
  161. return Math.round(ms / m) + 'm';
  162. }
  163. if (msAbs >= s) {
  164. return Math.round(ms / s) + 's';
  165. }
  166. return ms + 'ms';
  167. }
  168. /**
  169. * Long format for `ms`.
  170. *
  171. * @param {Number} ms
  172. * @return {String}
  173. * @api private
  174. */
  175. function fmtLong(ms) {
  176. var msAbs = Math.abs(ms);
  177. if (msAbs >= d) {
  178. return plural(ms, msAbs, d, 'day');
  179. }
  180. if (msAbs >= h) {
  181. return plural(ms, msAbs, h, 'hour');
  182. }
  183. if (msAbs >= m) {
  184. return plural(ms, msAbs, m, 'minute');
  185. }
  186. if (msAbs >= s) {
  187. return plural(ms, msAbs, s, 'second');
  188. }
  189. return ms + ' ms';
  190. }
  191. /**
  192. * Pluralization helper.
  193. */
  194. function plural(ms, msAbs, n, name) {
  195. var isPlural = msAbs >= n * 1.5;
  196. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  197. }
  198. }, {}],
  199. 2: [function (require, module, exports) {
  200. // shim for using process in browser
  201. var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
  202. // don't break things. But we need to wrap it in a try catch in case it is
  203. // wrapped in strict mode code which doesn't define any globals. It's inside a
  204. // function because try/catches deoptimize in certain engines.
  205. var cachedSetTimeout;
  206. var cachedClearTimeout;
  207. function defaultSetTimout() {
  208. throw new Error('setTimeout has not been defined');
  209. }
  210. function defaultClearTimeout() {
  211. throw new Error('clearTimeout has not been defined');
  212. }
  213. (function () {
  214. try {
  215. if (typeof setTimeout === 'function') {
  216. cachedSetTimeout = setTimeout;
  217. } else {
  218. cachedSetTimeout = defaultSetTimout;
  219. }
  220. } catch (e) {
  221. cachedSetTimeout = defaultSetTimout;
  222. }
  223. try {
  224. if (typeof clearTimeout === 'function') {
  225. cachedClearTimeout = clearTimeout;
  226. } else {
  227. cachedClearTimeout = defaultClearTimeout;
  228. }
  229. } catch (e) {
  230. cachedClearTimeout = defaultClearTimeout;
  231. }
  232. })();
  233. function runTimeout(fun) {
  234. if (cachedSetTimeout === setTimeout) {
  235. //normal enviroments in sane situations
  236. return setTimeout(fun, 0);
  237. } // if setTimeout wasn't available but was latter defined
  238. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  239. cachedSetTimeout = setTimeout;
  240. return setTimeout(fun, 0);
  241. }
  242. try {
  243. // when when somebody has screwed with setTimeout but no I.E. maddness
  244. return cachedSetTimeout(fun, 0);
  245. } catch (e) {
  246. try {
  247. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  248. return cachedSetTimeout.call(null, fun, 0);
  249. } catch (e) {
  250. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  251. return cachedSetTimeout.call(this, fun, 0);
  252. }
  253. }
  254. }
  255. function runClearTimeout(marker) {
  256. if (cachedClearTimeout === clearTimeout) {
  257. //normal enviroments in sane situations
  258. return clearTimeout(marker);
  259. } // if clearTimeout wasn't available but was latter defined
  260. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  261. cachedClearTimeout = clearTimeout;
  262. return clearTimeout(marker);
  263. }
  264. try {
  265. // when when somebody has screwed with setTimeout but no I.E. maddness
  266. return cachedClearTimeout(marker);
  267. } catch (e) {
  268. try {
  269. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  270. return cachedClearTimeout.call(null, marker);
  271. } catch (e) {
  272. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  273. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  274. return cachedClearTimeout.call(this, marker);
  275. }
  276. }
  277. }
  278. var queue = [];
  279. var draining = false;
  280. var currentQueue;
  281. var queueIndex = -1;
  282. function cleanUpNextTick() {
  283. if (!draining || !currentQueue) {
  284. return;
  285. }
  286. draining = false;
  287. if (currentQueue.length) {
  288. queue = currentQueue.concat(queue);
  289. } else {
  290. queueIndex = -1;
  291. }
  292. if (queue.length) {
  293. drainQueue();
  294. }
  295. }
  296. function drainQueue() {
  297. if (draining) {
  298. return;
  299. }
  300. var timeout = runTimeout(cleanUpNextTick);
  301. draining = true;
  302. var len = queue.length;
  303. while (len) {
  304. currentQueue = queue;
  305. queue = [];
  306. while (++queueIndex < len) {
  307. if (currentQueue) {
  308. currentQueue[queueIndex].run();
  309. }
  310. }
  311. queueIndex = -1;
  312. len = queue.length;
  313. }
  314. currentQueue = null;
  315. draining = false;
  316. runClearTimeout(timeout);
  317. }
  318. process.nextTick = function (fun) {
  319. var args = new Array(arguments.length - 1);
  320. if (arguments.length > 1) {
  321. for (var i = 1; i < arguments.length; i++) {
  322. args[i - 1] = arguments[i];
  323. }
  324. }
  325. queue.push(new Item(fun, args));
  326. if (queue.length === 1 && !draining) {
  327. runTimeout(drainQueue);
  328. }
  329. }; // v8 likes predictible objects
  330. function Item(fun, array) {
  331. this.fun = fun;
  332. this.array = array;
  333. }
  334. Item.prototype.run = function () {
  335. this.fun.apply(null, this.array);
  336. };
  337. process.title = 'browser';
  338. process.browser = true;
  339. process.env = {};
  340. process.argv = [];
  341. process.version = ''; // empty string to avoid regexp issues
  342. process.versions = {};
  343. function noop() {}
  344. process.on = noop;
  345. process.addListener = noop;
  346. process.once = noop;
  347. process.off = noop;
  348. process.removeListener = noop;
  349. process.removeAllListeners = noop;
  350. process.emit = noop;
  351. process.prependListener = noop;
  352. process.prependOnceListener = noop;
  353. process.listeners = function (name) {
  354. return [];
  355. };
  356. process.binding = function (name) {
  357. throw new Error('process.binding is not supported');
  358. };
  359. process.cwd = function () {
  360. return '/';
  361. };
  362. process.chdir = function (dir) {
  363. throw new Error('process.chdir is not supported');
  364. };
  365. process.umask = function () {
  366. return 0;
  367. };
  368. }, {}],
  369. 3: [function (require, module, exports) {
  370. /**
  371. * This is the common logic for both the Node.js and web browser
  372. * implementations of `debug()`.
  373. */
  374. function setup(env) {
  375. createDebug.debug = createDebug;
  376. createDebug.default = createDebug;
  377. createDebug.coerce = coerce;
  378. createDebug.disable = disable;
  379. createDebug.enable = enable;
  380. createDebug.enabled = enabled;
  381. createDebug.humanize = require('ms');
  382. Object.keys(env).forEach(function (key) {
  383. createDebug[key] = env[key];
  384. });
  385. /**
  386. * Active `debug` instances.
  387. */
  388. createDebug.instances = [];
  389. /**
  390. * The currently active debug mode names, and names to skip.
  391. */
  392. createDebug.names = [];
  393. createDebug.skips = [];
  394. /**
  395. * Map of special "%n" handling functions, for the debug "format" argument.
  396. *
  397. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  398. */
  399. createDebug.formatters = {};
  400. /**
  401. * Selects a color for a debug namespace
  402. * @param {String} namespace The namespace string for the for the debug instance to be colored
  403. * @return {Number|String} An ANSI color code for the given namespace
  404. * @api private
  405. */
  406. function selectColor(namespace) {
  407. var hash = 0;
  408. for (var i = 0; i < namespace.length; i++) {
  409. hash = (hash << 5) - hash + namespace.charCodeAt(i);
  410. hash |= 0; // Convert to 32bit integer
  411. }
  412. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  413. }
  414. createDebug.selectColor = selectColor;
  415. /**
  416. * Create a debugger with the given `namespace`.
  417. *
  418. * @param {String} namespace
  419. * @return {Function}
  420. * @api public
  421. */
  422. function createDebug(namespace) {
  423. var prevTime;
  424. function debug() {
  425. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  426. args[_key] = arguments[_key];
  427. }
  428. // Disabled?
  429. if (!debug.enabled) {
  430. return;
  431. }
  432. var self = debug; // Set `diff` timestamp
  433. var curr = Number(new Date());
  434. var ms = curr - (prevTime || curr);
  435. self.diff = ms;
  436. self.prev = prevTime;
  437. self.curr = curr;
  438. prevTime = curr;
  439. args[0] = createDebug.coerce(args[0]);
  440. if (typeof args[0] !== 'string') {
  441. // Anything else let's inspect with %O
  442. args.unshift('%O');
  443. } // Apply any `formatters` transformations
  444. var index = 0;
  445. args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
  446. // If we encounter an escaped % then don't increase the array index
  447. if (match === '%%') {
  448. return match;
  449. }
  450. index++;
  451. var formatter = createDebug.formatters[format];
  452. if (typeof formatter === 'function') {
  453. var val = args[index];
  454. match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
  455. args.splice(index, 1);
  456. index--;
  457. }
  458. return match;
  459. }); // Apply env-specific formatting (colors, etc.)
  460. createDebug.formatArgs.call(self, args);
  461. var logFn = self.log || createDebug.log;
  462. logFn.apply(self, args);
  463. }
  464. debug.namespace = namespace;
  465. debug.enabled = createDebug.enabled(namespace);
  466. debug.useColors = createDebug.useColors();
  467. debug.color = selectColor(namespace);
  468. debug.destroy = destroy;
  469. debug.extend = extend; // Debug.formatArgs = formatArgs;
  470. // debug.rawLog = rawLog;
  471. // env-specific initialization logic for debug instances
  472. if (typeof createDebug.init === 'function') {
  473. createDebug.init(debug);
  474. }
  475. createDebug.instances.push(debug);
  476. return debug;
  477. }
  478. function destroy() {
  479. var index = createDebug.instances.indexOf(this);
  480. if (index !== -1) {
  481. createDebug.instances.splice(index, 1);
  482. return true;
  483. }
  484. return false;
  485. }
  486. function extend(namespace, delimiter) {
  487. return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  488. }
  489. /**
  490. * Enables a debug mode by namespaces. This can include modes
  491. * separated by a colon and wildcards.
  492. *
  493. * @param {String} namespaces
  494. * @api public
  495. */
  496. function enable(namespaces) {
  497. createDebug.save(namespaces);
  498. createDebug.names = [];
  499. createDebug.skips = [];
  500. var i;
  501. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  502. var len = split.length;
  503. for (i = 0; i < len; i++) {
  504. if (!split[i]) {
  505. // ignore empty strings
  506. continue;
  507. }
  508. namespaces = split[i].replace(/\*/g, '.*?');
  509. if (namespaces[0] === '-') {
  510. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  511. } else {
  512. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  513. }
  514. }
  515. for (i = 0; i < createDebug.instances.length; i++) {
  516. var instance = createDebug.instances[i];
  517. instance.enabled = createDebug.enabled(instance.namespace);
  518. }
  519. }
  520. /**
  521. * Disable debug output.
  522. *
  523. * @api public
  524. */
  525. function disable() {
  526. createDebug.enable('');
  527. }
  528. /**
  529. * Returns true if the given mode name is enabled, false otherwise.
  530. *
  531. * @param {String} name
  532. * @return {Boolean}
  533. * @api public
  534. */
  535. function enabled(name) {
  536. if (name[name.length - 1] === '*') {
  537. return true;
  538. }
  539. var i;
  540. var len;
  541. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  542. if (createDebug.skips[i].test(name)) {
  543. return false;
  544. }
  545. }
  546. for (i = 0, len = createDebug.names.length; i < len; i++) {
  547. if (createDebug.names[i].test(name)) {
  548. return true;
  549. }
  550. }
  551. return false;
  552. }
  553. /**
  554. * Coerce `val`.
  555. *
  556. * @param {Mixed} val
  557. * @return {Mixed}
  558. * @api private
  559. */
  560. function coerce(val) {
  561. if (val instanceof Error) {
  562. return val.stack || val.message;
  563. }
  564. return val;
  565. }
  566. createDebug.enable(createDebug.load());
  567. return createDebug;
  568. }
  569. module.exports = setup;
  570. }, {
  571. "ms": 1
  572. }],
  573. 4: [function (require, module, exports) {
  574. (function (process) {
  575. /* eslint-env browser */
  576. /**
  577. * This is the web browser implementation of `debug()`.
  578. */
  579. exports.log = log;
  580. exports.formatArgs = formatArgs;
  581. exports.save = save;
  582. exports.load = load;
  583. exports.useColors = useColors;
  584. exports.storage = localstorage();
  585. /**
  586. * Colors.
  587. */
  588. exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
  589. /**
  590. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  591. * and the Firebug extension (any Firefox version) are known
  592. * to support "%c" CSS customizations.
  593. *
  594. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  595. */
  596. // eslint-disable-next-line complexity
  597. function useColors() {
  598. // NB: In an Electron preload script, document will be defined but not fully
  599. // initialized. Since we know we're in Chrome, we'll just detect this case
  600. // explicitly
  601. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  602. return true;
  603. } // Internet Explorer and Edge do not support colors.
  604. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  605. return false;
  606. } // Is webkit? http://stackoverflow.com/a/16459606/376773
  607. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  608. return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
  609. typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
  610. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  611. typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
  612. typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
  613. }
  614. /**
  615. * Colorize log arguments if enabled.
  616. *
  617. * @api public
  618. */
  619. function formatArgs(args) {
  620. args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
  621. if (!this.useColors) {
  622. return;
  623. }
  624. var c = 'color: ' + this.color;
  625. args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
  626. // arguments passed either before or after the %c, so we need to
  627. // figure out the correct index to insert the CSS into
  628. var index = 0;
  629. var lastC = 0;
  630. args[0].replace(/%[a-zA-Z%]/g, function (match) {
  631. if (match === '%%') {
  632. return;
  633. }
  634. index++;
  635. if (match === '%c') {
  636. // We only are interested in the *last* %c
  637. // (the user may have provided their own)
  638. lastC = index;
  639. }
  640. });
  641. args.splice(lastC, 0, c);
  642. }
  643. /**
  644. * Invokes `console.log()` when available.
  645. * No-op when `console.log` is not a "function".
  646. *
  647. * @api public
  648. */
  649. function log() {
  650. var _console;
  651. // This hackery is required for IE8/9, where
  652. // the `console.log` function doesn't have 'apply'
  653. return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
  654. }
  655. /**
  656. * Save `namespaces`.
  657. *
  658. * @param {String} namespaces
  659. * @api private
  660. */
  661. function save(namespaces) {
  662. try {
  663. if (namespaces) {
  664. exports.storage.setItem('debug', namespaces);
  665. } else {
  666. exports.storage.removeItem('debug');
  667. }
  668. } catch (error) {// Swallow
  669. // XXX (@Qix-) should we be logging these?
  670. }
  671. }
  672. /**
  673. * Load `namespaces`.
  674. *
  675. * @return {String} returns the previously persisted debug modes
  676. * @api private
  677. */
  678. function load() {
  679. var r;
  680. try {
  681. r = exports.storage.getItem('debug');
  682. } catch (error) {} // Swallow
  683. // XXX (@Qix-) should we be logging these?
  684. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  685. if (!r && typeof process !== 'undefined' && 'env' in process) {
  686. r = process.env.DEBUG;
  687. }
  688. return r;
  689. }
  690. /**
  691. * Localstorage attempts to return the localstorage.
  692. *
  693. * This is necessary because safari throws
  694. * when a user disables cookies/localstorage
  695. * and you attempt to access it.
  696. *
  697. * @return {LocalStorage}
  698. * @api private
  699. */
  700. function localstorage() {
  701. try {
  702. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  703. // The Browser also has localStorage in the global context.
  704. return localStorage;
  705. } catch (error) {// Swallow
  706. // XXX (@Qix-) should we be logging these?
  707. }
  708. }
  709. module.exports = require('./common')(exports);
  710. var formatters = module.exports.formatters;
  711. /**
  712. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  713. */
  714. formatters.j = function (v) {
  715. try {
  716. return JSON.stringify(v);
  717. } catch (error) {
  718. return '[UnexpectedJSONParseError]: ' + error.message;
  719. }
  720. };
  721. }).call(this, require('_process'));
  722. }, {
  723. "./common": 3,
  724. "_process": 2
  725. }]
  726. }, {}, [4])(4);
  727. });