MCPcopy Index your code
hub / github.com/nodejs/node / initializeGlobalConsole

Function initializeGlobalConsole

lib/internal/console/constructor.js:683–712  ·  view source on GitHub ↗
(globalConsole)

Source from the content-addressed store, hash-verified

681Console.prototype.groupCollapsed = Console.prototype.group;
682
683function initializeGlobalConsole(globalConsole) {
684 globalConsole[kBindStreamsLazy](process);
685 const {
686 namespace: {
687 addSerializeCallback,
688 isBuildingSnapshot,
689 },
690 } = require('internal/v8/startup_snapshot');
691
692 if (!internalBinding('config').hasInspector || !isBuildingSnapshot()) {
693 return;
694 }
695 const { console: consoleFromVM } = internalBinding('inspector');
696 const nodeConsoleKeys = ObjectKeys(Console.prototype);
697 const vmConsoleKeys = ObjectKeys(consoleFromVM);
698 const originalKeys = new SafeSet(vmConsoleKeys.concat(nodeConsoleKeys));
699 const inspectorConsoleKeys = new SafeSet();
700 for (const key of ObjectKeys(globalConsole)) {
701 if (!originalKeys.has(key)) {
702 inspectorConsoleKeys.add(key);
703 }
704 }
705 // During deserialization these should be reinstalled to console by
706 // V8 when the inspector client is created.
707 addSerializeCallback(() => {
708 for (const key of inspectorConsoleKeys) {
709 globalConsole[key] = undefined;
710 }
711 });
712}
713
714module.exports = {
715 Console,

Callers 1

patchProcessObjectFunction · 0.85

Calls 6

isBuildingSnapshotFunction · 0.85
addSerializeCallbackFunction · 0.85
concatMethod · 0.80
hasMethod · 0.65
addMethod · 0.65
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…