diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-05 18:40:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 18:40:24 +0200 |
commit | 2aed322dd507a8568b6ee6f4897e9a8e3220f763 (patch) | |
tree | e9a45c0b7688a9881ea9ce132b92554ef2955ad6 /runtime/js/30_os.js | |
parent | 284e6c303956e8ca20af63b4ecc045438a260fe6 (diff) |
refactor: convert ops to use serde_v8 (#10009)
This commit rewrites most of the ops to use "serde_v8" instead
of "json" serialization.
Diffstat (limited to 'runtime/js/30_os.js')
-rw-r--r-- | runtime/js/30_os.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 23c3d8de6..0ce831775 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -21,7 +21,12 @@ } function systemCpuInfo() { - return core.jsonOpSync("op_system_cpu_info"); + const { cores, speed } = core.jsonOpSync("op_system_cpu_info"); + // Map nulls to undefined for compatibility + return { + cores: cores ?? undefined, + speed: speed ?? undefined, + }; } // This is an internal only method used by the test harness to override the @@ -44,7 +49,7 @@ return; } - core.jsonOpSync("op_exit", { code }); + core.jsonOpSync("op_exit", code); throw new Error("Code not reachable"); } @@ -53,11 +58,11 @@ } function getEnv(key) { - return core.jsonOpSync("op_get_env", { key })[0]; + return core.jsonOpSync("op_get_env", key) ?? undefined; } function deleteEnv(key) { - core.jsonOpSync("op_delete_env", { key }); + core.jsonOpSync("op_delete_env", key); } const env = { |