.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / prettier-stylelint / node_modules / debug / src / browser.js
1 "use strict";
2
3 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); }
4
5 /* eslint-env browser */
6
7 /**
8  * This is the web browser implementation of `debug()`.
9  */
10 exports.log = log;
11 exports.formatArgs = formatArgs;
12 exports.save = save;
13 exports.load = load;
14 exports.useColors = useColors;
15 exports.storage = localstorage();
16 /**
17  * Colors.
18  */
19
20 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'];
21 /**
22  * Currently only WebKit-based Web Inspectors, Firefox >= v31,
23  * and the Firebug extension (any Firefox version) are known
24  * to support "%c" CSS customizations.
25  *
26  * TODO: add a `localStorage` variable to explicitly enable/disable colors
27  */
28 // eslint-disable-next-line complexity
29
30 function useColors() {
31   // NB: In an Electron preload script, document will be defined but not fully
32   // initialized. Since we know we're in Chrome, we'll just detect this case
33   // explicitly
34   if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
35     return true;
36   } // Internet Explorer and Edge do not support colors.
37
38
39   if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
40     return false;
41   } // Is webkit? http://stackoverflow.com/a/16459606/376773
42   // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
43
44
45   return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
46   typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
47   // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
48   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
49   typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
50 }
51 /**
52  * Colorize log arguments if enabled.
53  *
54  * @api public
55  */
56
57
58 function formatArgs(args) {
59   args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
60
61   if (!this.useColors) {
62     return;
63   }
64
65   var c = 'color: ' + this.color;
66   args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
67   // arguments passed either before or after the %c, so we need to
68   // figure out the correct index to insert the CSS into
69
70   var index = 0;
71   var lastC = 0;
72   args[0].replace(/%[a-zA-Z%]/g, function (match) {
73     if (match === '%%') {
74       return;
75     }
76
77     index++;
78
79     if (match === '%c') {
80       // We only are interested in the *last* %c
81       // (the user may have provided their own)
82       lastC = index;
83     }
84   });
85   args.splice(lastC, 0, c);
86 }
87 /**
88  * Invokes `console.log()` when available.
89  * No-op when `console.log` is not a "function".
90  *
91  * @api public
92  */
93
94
95 function log() {
96   var _console;
97
98   // This hackery is required for IE8/9, where
99   // the `console.log` function doesn't have 'apply'
100   return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
101 }
102 /**
103  * Save `namespaces`.
104  *
105  * @param {String} namespaces
106  * @api private
107  */
108
109
110 function save(namespaces) {
111   try {
112     if (namespaces) {
113       exports.storage.setItem('debug', namespaces);
114     } else {
115       exports.storage.removeItem('debug');
116     }
117   } catch (error) {// Swallow
118     // XXX (@Qix-) should we be logging these?
119   }
120 }
121 /**
122  * Load `namespaces`.
123  *
124  * @return {String} returns the previously persisted debug modes
125  * @api private
126  */
127
128
129 function load() {
130   var r;
131
132   try {
133     r = exports.storage.getItem('debug');
134   } catch (error) {} // Swallow
135   // XXX (@Qix-) should we be logging these?
136   // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
137
138
139   if (!r && typeof process !== 'undefined' && 'env' in process) {
140     r = process.env.DEBUG;
141   }
142
143   return r;
144 }
145 /**
146  * Localstorage attempts to return the localstorage.
147  *
148  * This is necessary because safari throws
149  * when a user disables cookies/localstorage
150  * and you attempt to access it.
151  *
152  * @return {LocalStorage}
153  * @api private
154  */
155
156
157 function localstorage() {
158   try {
159     // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
160     // The Browser also has localStorage in the global context.
161     return localStorage;
162   } catch (error) {// Swallow
163     // XXX (@Qix-) should we be logging these?
164   }
165 }
166
167 module.exports = require('./common')(exports);
168 var formatters = module.exports.formatters;
169 /**
170  * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
171  */
172
173 formatters.j = function (v) {
174   try {
175     return JSON.stringify(v);
176   } catch (error) {
177     return '[UnexpectedJSONParseError]: ' + error.message;
178   }
179 };
180