diff options
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index a48105559..16a444098 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -247,6 +247,8 @@ delete Object.prototype.__proto__; const navigator = webidl.createBranded(Navigator); + let numCpus; + ObjectDefineProperties(Navigator.prototype, { gpu: { configurable: true, @@ -256,6 +258,14 @@ delete Object.prototype.__proto__; return webgpu.gpu; }, }, + hardwareConcurrency: { + configurable: true, + enumerable: true, + get() { + webidl.assertBranded(this, Navigator); + return numCpus; + }, + }, }); class WorkerNavigator { @@ -279,6 +289,14 @@ delete Object.prototype.__proto__; return webgpu.gpu; }, }, + hardwareConcurrency: { + configurable: true, + enumerable: true, + get() { + webidl.assertBranded(this, Navigator); + return numCpus; + }, + }, }); // https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope @@ -491,12 +509,13 @@ delete Object.prototype.__proto__; pid, ppid, unstableFlag, + cpuCount, } = runtimeOptions; if (locationHref != null) { location.setLocationHref(locationHref); } - + numCpus = cpuCount; registerErrors(); const internalSymbol = Symbol("Deno.internal"); @@ -566,10 +585,17 @@ delete Object.prototype.__proto__; runtimeOptions, internalName ?? name, ); - const { unstableFlag, pid, noColor, args, location: locationHref } = - runtimeOptions; + const { + unstableFlag, + pid, + noColor, + args, + location: locationHref, + cpuCount, + } = runtimeOptions; location.setLocationHref(locationHref); + numCpus = cpuCount; registerErrors(); pollForMessages(); |