MCPcopy Index your code
hub / github.com/PrairieLearn/PrairieLearn / enabled

Function enabled

public/javascripts/socket.io.js:739–790  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

737
738 // define the `enabled` version
739 function enabled() {
740
741 var self = enabled;
742
743 // set `diff` timestamp
744 var curr = +new Date();
745 var ms = curr - (prevTime || curr);
746 self.diff = ms;
747 self.prev = prevTime;
748 self.curr = curr;
749 prevTime = curr;
750
751 // add the `color` if not set
752 if (null == self.useColors) self.useColors = exports.useColors();
753 if (null == self.color && self.useColors) self.color = selectColor();
754
755 var args = new Array(arguments.length);
756 for (var i = 0; i < args.length; i++) {
757 args[i] = arguments[i];
758 }
759
760 args[0] = exports.coerce(args[0]);
761
762 if ('string' !== typeof args[0]) {
763 // anything else let's inspect with %o
764 args = ['%o'].concat(args);
765 }
766
767 // apply any `formatters` transformations
768 var index = 0;
769 args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
770 // if we encounter an escaped % then don't increase the array index
771 if (match === '%%') return match;
772 index++;
773 var formatter = exports.formatters[format];
774 if ('function' === typeof formatter) {
775 var val = args[index];
776 match = formatter.call(self, val);
777
778 // now we need to remove `args[index]` since it's inlined in the `format`
779 args.splice(index, 1);
780 index--;
781 }
782 return match;
783 });
784
785 // apply env-specific formatting
786 args = exports.formatArgs.apply(self, args);
787
788 var logFn = enabled.log || exports.log || console.log.bind(console);
789 logFn.apply(self, args);
790 }
791 enabled.enabled = true;
792
793 var fn = exports.enabled(namespace) ? enabled : disabled;

Callers

nothing calls this directly

Calls 2

selectColorFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected