PageSourceSearch

https://knowledgecheckr.at/tmp/assets/ab94258f/build/lslog.js

js knowledgecheckr.at collected 2026-10-06 07:59:31 UTC 7,891 bytes, 230 lines download raw bytes

1'use strict';
2
3var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
5function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
6
7function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
9/**
10 * Check the browsers console capabilities and bundle them into general functions
11 * If the build environment was "production" only put out error messages.
12 */
13
14var ConsoleShim = function () {
15    function ConsoleShim() {
16        var param = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
17        var silencer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
18
19        _classCallCheck(this, ConsoleShim);
20
21        this.param = param;
22        this.silencer = silencer;
23        this.collector = [];
24        this.currentGroupDescription = '';
25        this.activeGroups = 0;
26        this.timeHolder = null;
27        this.methods = ['group', 'groupEnd', 'log', 'trace', 'time', 'timeEnd', 'error', 'warn'];
28
29        this.silent = {
30            group: function group() {
31                return;
32            },
33            groupEnd: function groupEnd() {
34                return;
35            },
36            log: function log() {
37                return;
38            },
39            trace: function trace() {
40                return;
41            },
42            time: function time() {
43                return;
44            },
45            timeEnd: function timeEnd() {
46                return;
47            },
48            error: function error() {
49                return;
50            },
51            err: function err() {
52                return;
53            },
54            debug: function debug() {
55                return;
56            },
57            warn: function warn() {
58                return;
59            }
60        };
61    }
62
63    _createClass(ConsoleShim, [{
64        key: '_generateError',
65        value: function _generateError() {
66            try {
67                throw new Error();
68            } catch (err) {
69                return err;
70            }
71        }
72    }, {
73        key: '_insertParamToArguments',
74        value: function _insertParamToArguments(rawArgs) {
75            if (this.param !== '') {
76                var args = [].concat(_toConsumableArray(rawArgs));
77                args.unshift(this.param);
78                return args;
79            }
80            return Array.from(arguments);
81        }
82    }, {
83        key: 'setSilent',
84        value: function setSilent() {
85            var newValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
86
87            this.silencer = newValue || !this.silencer;
88        }
89        //Start grouping logs
90
91    }, {
92        key: 'group',
93        value: function group() {
94            if (this.silencer) {
95                return;
96            }
97            var args = this._insertParamToArguments(arguments);
98            if (typeof console.group === 'function') {
99                console.group.apply(console, args);
100                return;
101            }
102            var description = args[0] || 'GROUP';
103            this.currentGroupDescription = description;
104            this.activeGroups++;
105        }
106        //Stop grouping logs
107
108    }, {
109        key: 'groupEnd',
110        value: function groupEnd() {
111            if (this.silencer) {
112                return;
113            }
114            var args = this._insertParamToArguments(arguments);
115            if (typeof console.groupEnd === 'function') {
116                console.groupEnd.apply(console, args);
117                return;
118            }
119            this.currentGroupDescription = '';
120            this.activeGroups--;
121            this.activeGroups = this.activeGroups === 0 ? 0 : this.activeGroups--;
122        }
123        //Simplest mechanism to log stuff
124        // Aware of the group shim
125
126    }, {
127        key: 'log',
128        value: function log() {
129            if (this.silencer) {
130                return;
131            }
132            var args = this._insertParamToArguments(arguments);
133            if (typeof console.group === 'function') {
134                console.log.apply(console, args);
135                return;
136            }
137            args.shift();
138            args.unshift(' '.repeat(this.activeGroups * 2));
139            this.log.apply(this, args);
140        }
141        //Trace back the apply.
142        //Uses either the inbuilt function console trace or opens a shim to trace by calling this._insertParamToArguments(arguments).callee
143
144    }, {
145        key: 'trace',
146        value: function trace() {
147            if (this.silencer) {
148                return;
149            }
150            var args = this._insertParamToArguments(arguments);
151            if (typeof console.trace === 'function') {
152                console.trace.apply(console, args);
153                return;
154            }
155            var artificialError = this._generateError();
156            if (artificialError.stack) {
157                this.log.apply(console, artificialError.stack);
158                return;
159            }
160
161            this.log(args);
162            if (arguments.callee != undefined) {
163                this.trace.apply(console, arguments.callee);
164            }
165        }
166    }, {
167        key: 'time',
168        value: function time() {
169            if (this.silencer) {
170                return;
171            }
172            var args = this._insertParamToArguments(arguments);
173            if (typeof console.time === 'function') {
174                console.time.apply(console, args);
175                return;
176            }
177
178            this.timeHolder = new Date();
179        }
180    }, {
181        key: 'timeEnd',
182        value: function timeEnd() {
183            if (this.silencer) {
184                return;
185            }
186            var args = this._insertParamToArguments(arguments);
187            if (typeof console.timeEnd === 'function') {
188                console.timeEnd.apply(console, args);
189                return;
190            }
191            var diff = new Date() - this.timeHolder;
192            this.log('Took ' + Math.floor(diff / (1000 * 60 * 60)) + ' hours, ' + Math.floor(diff / (1000 * 60)) + ' minutes and ' + Math.floor(diff / 1000) + ' seconds ( ' + diff + ' ms)');
193            this.time = new Date();
194        }
195    }, {
196        key: 'error',
197        value: function error() {
198            var args = this._insertParamToArguments(arguments);
199            if (typeof console.error === 'function') {
200                console.error.apply(console, args);
201                return;
202            }
203
204            this.log('--- ERROR ---');
205            this.log(args);
206        }
207    }, {
208        key: 'warn',
209        value: function warn() {
210            var args = this._insertParamToArguments(arguments);
211            if (typeof console.warn === 'function') {
212                console.warn.apply(console, args);
213                return;
214            }
215
216            this.log('--- WARN ---');
217            this.log(args);
218        }
219    }]);
220
221    return ConsoleShim;
222}();
223
224if (window.debugState.backend || window.debugState.frontend) {
225    var globalLSConsole = new ConsoleShim('LSLOG');
226    window.console.ls = globalLSConsole;
227} else {
228    var globalLSConsole = new ConsoleShim('LSLOG', true);
229    window.console.ls = globalLSConsole;
230}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.