MCPcopy
hub / github.com/socketio/socket.io / debug

Function debug

packages/socket.io/client-dist/socket.io.js:2576–2623  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2574 var namespacesCache;
2575 var enabledCache;
2576 function debug() {
2577 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2578 args[_key] = arguments[_key];
2579 }
2580 // Disabled?
2581 if (!debug.enabled) {
2582 return;
2583 }
2584 var self = debug;
2585
2586 // Set `diff` timestamp
2587 var curr = Number(new Date());
2588 var ms = curr - (prevTime || curr);
2589 self.diff = ms;
2590 self.prev = prevTime;
2591 self.curr = curr;
2592 prevTime = curr;
2593 args[0] = createDebug.coerce(args[0]);
2594 if (typeof args[0] !== 'string') {
2595 // Anything else let's inspect with %O
2596 args.unshift('%O');
2597 }
2598
2599 // Apply any `formatters` transformations
2600 var index = 0;
2601 args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
2602 // If we encounter an escaped % then don't increase the array index
2603 if (match === '%%') {
2604 return '%';
2605 }
2606 index++;
2607 var formatter = createDebug.formatters[format];
2608 if (typeof formatter === 'function') {
2609 var val = args[index];
2610 match = formatter.call(self, val);
2611
2612 // Now we need to remove `args[index]` since it's inlined in the `format`
2613 args.splice(index, 1);
2614 index--;
2615 }
2616 return match;
2617 });
2618
2619 // Apply env-specific formatting (colors, etc.)
2620 createDebug.formatArgs.call(self, args);
2621 var logFn = self.log || createDebug.log;
2622 logFn.apply(self, args);
2623 }
2624 debug.namespace = namespace;
2625 debug.useColors = createDebug.useColors();
2626 debug.color = createDebug.selectColor(namespace);

Callers 15

socket.tsFile · 0.85
constructorMethod · 0.85
createTransportMethod · 0.85
setTransportMethod · 0.85
onOpenMethod · 0.85
_onPacketMethod · 0.85
flushMethod · 0.85
_getWritablePacketsMethod · 0.85
_hasPingExpiredMethod · 0.85
closeMethod · 0.85
_onErrorMethod · 0.85
_onCloseMethod · 0.85

Calls 1

applyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…