1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.safeConsole = void 0;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | var common_1 = require("./common");
|
10 | var noopConsoleStub = { log: common_1.noop, error: common_1.noop, table: common_1.noop };
|
11 | function ie9Console(console) {
|
12 | var bound = function (fn) { return Function.prototype.bind.call(fn, console); };
|
13 | return {
|
14 | log: bound(console.log),
|
15 | error: bound(console.log),
|
16 | table: bound(console.log),
|
17 | };
|
18 | }
|
19 | function fallbackConsole(console) {
|
20 | var log = console.log.bind(console);
|
21 | var error = console.error ? console.error.bind(console) : log;
|
22 | var table = console.table ? console.table.bind(console) : log;
|
23 | return { log: log, error: error, table: table };
|
24 | }
|
25 | function getSafeConsole() {
|
26 |
|
27 | var isIE9 = typeof document !== 'undefined' && document.documentMode && document.documentMode === 9;
|
28 | if (isIE9) {
|
29 | return window && window.console ? ie9Console(window.console) : noopConsoleStub;
|
30 | }
|
31 | else if (!console.table || !console.error) {
|
32 | return fallbackConsole(console);
|
33 | }
|
34 | else {
|
35 | return console;
|
36 | }
|
37 | }
|
38 | exports.safeConsole = getSafeConsole();
|
39 |
|
\ | No newline at end of file |