Sha256: c1f9bc653b1a7d233786605cdc20dc4f399e1bccdeb0625b9cf01bcc11329b29
Contents?: true
Size: 1.68 KB
Versions: 5
Compression:
Stored size: 1.68 KB
Contents
(function (console) { var i, global = this, fnProto = Function.prototype, fnApply = fnProto.apply, fnBind = fnProto.bind, bind = function (context, fn) { return fnBind ? fnBind.call( fn, context ) : function () { return fnApply.call( fn, context, arguments ); }; }, methods = ['assert','count','debug','dir','dirxml','error','group','groupCollapsed','groupEnd','info','log','markTimeline','profile','profileEnd','table','time','timeEnd','trace','warn'], emptyFn = function(){}, empty = {}, timeCounters; for (i = methods.length; i--;) empty[methods[i]] = emptyFn; if (console) { if (!console.time) { console.timeCounters = timeCounters = {}; console.time = function(name, reset){ if (name) { var time = +new Date, key = "KEY" + name.toString(); if (reset || !timeCounters[key]) timeCounters[key] = time; } }; console.timeEnd = function(name){ var diff, time = +new Date, key = "KEY" + name.toString(), timeCounter = timeCounters[key]; if (timeCounter) { diff = time - timeCounter; console.info( name + ": " + diff + "ms" ); delete timeCounters[key]; } return diff; }; } for (i = methods.length; i--;) { console[methods[i]] = methods[i] in console ? bind(console, console[methods[i]]) : emptyFn; } console.disable = function () { global.console = empty; }; empty.enable = function () { global.console = console; }; empty.disable = console.enable = emptyFn; } else { console = global.console = empty; console.disable = console.enable = emptyFn; } })( typeof console === 'undefined' ? null : console );
Version data entries
5 entries across 5 versions & 1 rubygems