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