mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: create global console properties at snapshot build time
It is safe to create the console properties for the global console at snapshot build time. Streams must still be created lazily however because they need special synchronization for the handles. PR-URL: https://github.com/nodejs/node/pull/51700 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
@@ -694,8 +694,6 @@ Console.prototype.groupCollapsed = Console.prototype.group;
|
||||
|
||||
function initializeGlobalConsole(globalConsole) {
|
||||
globalConsole[kBindStreamsLazy](process);
|
||||
globalConsole[kBindProperties](true, 'auto');
|
||||
|
||||
const {
|
||||
namespace: {
|
||||
addSerializeCallback,
|
||||
|
||||
@@ -21,6 +21,7 @@ const {
|
||||
|
||||
const {
|
||||
Console,
|
||||
kBindProperties,
|
||||
} = require('internal/console/constructor');
|
||||
|
||||
const globalConsole = { __proto__: {} };
|
||||
@@ -41,6 +42,8 @@ for (const prop of ReflectOwnKeys(Console.prototype)) {
|
||||
ReflectDefineProperty(globalConsole, prop, desc);
|
||||
}
|
||||
|
||||
globalConsole[kBindProperties](true, 'auto');
|
||||
|
||||
// This is a legacy feature - the Console constructor is exposed on
|
||||
// the global console instance.
|
||||
globalConsole.Console = Console;
|
||||
|
||||
Reference in New Issue
Block a user