mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
refactor(runtime): don't use destructuring assignment in JS code (#16050)
This commit is contained in:
parent
a44c83a3d6
commit
1156f726a9
1 changed files with 19 additions and 43 deletions
|
@ -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".
|
||||
|
|
Loading…
Reference in a new issue