(globalConsole)
| 681 | Console.prototype.groupCollapsed = Console.prototype.group; |
| 682 | |
| 683 | function 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 | |
| 714 | module.exports = { |
| 715 | Console, |
no test coverage detected
searching dependent graphs…