summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-09-28 12:28:38 +0200
committerGitHub <noreply@github.com>2022-09-28 12:28:38 +0200
commit1156f726a92d3d3985e591327c7526cd3e2b0473 (patch)
treef0e605fa79aace9e7c0f0913b60d5eccde8c31d3 /runtime/js
parenta44c83a3d66a576e93f642ec475ea505215a8d62 (diff)
refactor(runtime): don't use destructuring assignment in JS code (#16050)
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/99_main.js64
1 files changed, 20 insertions, 44 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 27dc7111a..755eac939 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -252,8 +252,10 @@ delete Intl.v8BreakIterator;
);
build.setBuildInfo(runtimeOptions.target);
util.setLogDebug(runtimeOptions.debugFlag, source);
+ colors.setNoColor(runtimeOptions.noColor || !runtimeOptions.isTty);
// deno-lint-ignore prefer-primordials
Error.prepareStackTrace = core.prepareStackTrace;
+ registerErrors();
}
function registerErrors() {
@@ -639,19 +641,6 @@ delete Intl.v8BreakIterator;
throw new Error("Worker runtime already bootstrapped");
}
- const {
- args,
- location: locationHref,
- noColor,
- isTty,
- pid,
- ppid,
- unstableFlag,
- cpuCount,
- inspectFlag,
- userAgent: userAgentInfo,
- } = runtimeOptions;
-
performance.setTimeOrigin(DateNow());
const consoleFromV8 = window.console;
const wrapConsole = window.__bootstrap.console.wrapConsole;
@@ -665,12 +654,12 @@ delete Intl.v8BreakIterator;
// If the `--location` flag isn't set, make `globalThis.location` `undefined` and
// writable, so that they can mock it themselves if they like. If the flag was
// set, define `globalThis.location`, using the provided value.
- if (locationHref == null) {
+ if (runtimeOptions.location == null) {
mainRuntimeGlobalProperties.location = {
writable: true,
};
} else {
- location.setLocationHref(locationHref);
+ location.setLocationHref(runtimeOptions.location);
}
ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope);
@@ -680,7 +669,7 @@ delete Intl.v8BreakIterator;
ObjectDefineProperties(globalThis, mainRuntimeGlobalProperties);
ObjectSetPrototypeOf(globalThis, Window.prototype);
- if (inspectFlag) {
+ if (runtimeOptions.inspectFlag) {
const consoleFromDeno = globalThis.console;
wrapConsole(consoleFromDeno, consoleFromV8);
}
@@ -706,10 +695,8 @@ delete Intl.v8BreakIterator;
runtimeStart(runtimeOptions);
- colors.setNoColor(noColor || !isTty);
- numCpus = cpuCount;
- userAgent = userAgentInfo;
- registerErrors();
+ numCpus = runtimeOptions.cpuCount;
+ userAgent = runtimeOptions.userAgent;
const internalSymbol = Symbol("Deno.internal");
@@ -722,14 +709,14 @@ delete Intl.v8BreakIterator;
...denoNs,
};
ObjectDefineProperties(finalDenoNs, {
- pid: util.readOnly(pid),
- ppid: util.readOnly(ppid),
- noColor: util.readOnly(noColor),
- args: util.readOnly(ObjectFreeze(args)),
+ pid: util.readOnly(runtimeOptions.pid),
+ ppid: util.readOnly(runtimeOptions.ppid),
+ noColor: util.readOnly(runtimeOptions.noColor),
+ args: util.readOnly(ObjectFreeze(runtimeOptions.args)),
mainModule: util.getterOnly(opMainModule),
});
- if (unstableFlag) {
+ if (runtimeOptions.unstableFlag) {
ObjectAssign(finalDenoNs, denoNsUnstable);
}
@@ -738,7 +725,7 @@ delete Intl.v8BreakIterator;
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
ObjectFreeze(globalThis.Deno.core);
- util.log("args", args);
+ util.log("args", runtimeOptions.args);
}
function bootstrapWorkerRuntime(
@@ -795,20 +782,9 @@ delete Intl.v8BreakIterator;
runtimeOptions,
internalName ?? name,
);
- const {
- unstableFlag,
- pid,
- noColor,
- isTty,
- args,
- location: locationHref,
- cpuCount,
- } = runtimeOptions;
-
- colors.setNoColor(noColor || !isTty);
- location.setLocationHref(locationHref);
- numCpus = cpuCount;
- registerErrors();
+
+ location.setLocationHref(runtimeOptions.location);
+ numCpus = runtimeOptions.cpuCount;
globalThis.pollForMessages = pollForMessages;
@@ -822,13 +798,13 @@ delete Intl.v8BreakIterator;
close: core.close,
...denoNs,
};
- if (unstableFlag) {
+ if (runtimeOptions.unstableFlag) {
ObjectAssign(finalDenoNs, denoNsUnstable);
}
ObjectDefineProperties(finalDenoNs, {
- pid: util.readOnly(pid),
- noColor: util.readOnly(noColor),
- args: util.readOnly(ObjectFreeze(args)),
+ pid: util.readOnly(runtimeOptions.pid),
+ noColor: util.readOnly(runtimeOptions.noColor),
+ args: util.readOnly(ObjectFreeze(runtimeOptions.args)),
});
// Setup `Deno` global - we're actually overriding already
// existing global `Deno` with `Deno` namespace from "./deno.ts".