-
Notifications
You must be signed in to change notification settings - Fork 532
Expand file tree
/
Copy pathconsoleShim.js
More file actions
51 lines (49 loc) · 1.17 KB
/
Copy pathconsoleShim.js
File metadata and controls
51 lines (49 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @file Provide no-op fills for missing window.console methods. Doesn't add
* any special functionality, just makes the console safe to use on our
* supported browsers. Based on the fasted implementation I could find.
*
* @see http://jsperf.com/console-polyfill
* @see https://getfirebug.com/wiki/index.php/Console_API
*/
/**
* Call this method, passing in the window object, to fill missing console
* methods with no-op functions.
* @param {!Window} window
*/
module.exports = function (window) {
// Add console if it doesn't exist
var console = (window.console = window.console || {});
// Add methods (based on the Firebug Console API) if they don't exist
var methods = [
'assert',
'clear',
'count',
'debug',
'dir',
'dirxml',
'error',
'exception',
'group',
'groupCollapsed',
'groupEnd',
'info',
'log',
'markTimeline',
'profile',
'profileEnd',
'table',
'time',
'timeEnd',
'timeStamp',
'trace',
'warn',
];
var method;
for (var i = 0; i < methods.length; i++) {
method = methods[i];
if (!console[method]) {
console[method] = function () {};
}
}
};