Evaluate console._muted at load time

Convert console._muted from a function to a boolean by invoking an IIFE during module initialization. This reads the WScript 'quiet' flag once and stores the result, and updates _echoCallback to reference the boolean (remove the function call). This simplifies usage and avoids repeated runtime checks.
This commit is contained in:
Namhyeon, Go 2026-04-12 19:18:46 +09:00
parent 4c48fdbb4d
commit 55f6f1c438

6
app.js
View File

@ -36,16 +36,16 @@ var console = {
} }
return res; return res;
}, },
_muted: function() { _muted: (function() {
try { try {
if (typeof WScript !== "undefined") if (typeof WScript !== "undefined")
return WScript.Arguments.Named.Exists("quiet"); return WScript.Arguments.Named.Exists("quiet");
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
return false; return false;
}, })(),
_echoCallback: function(params, type) { _echoCallback: function(params, type) {
if (this._muted()) return; if (this._muted) return;
if (typeof WScript !== "undefined") { if (typeof WScript !== "undefined") {
WScript.StdOut.WriteLine("[*] " + params.message); WScript.StdOut.WriteLine("[*] " + params.message);