summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/os.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-01-02 19:27:54 +0530
committerGitHub <noreply@github.com>2024-01-02 14:57:54 +0100
commit9f7586a20691e5adb080f60f569498844f8a295f (patch)
tree0b256481c33216b2a42a94693d6a8c44aa97cead /ext/node/polyfills/os.ts
parent8e4feacd258b2fc019f2b9612133231fa8be14c0 (diff)
fix(ext/node): implement os.machine (#21751)
Diffstat (limited to 'ext/node/polyfills/os.ts')
-rw-r--r--ext/node/polyfills/os.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts
index 83e56e9f4..af3e69d64 100644
--- a/ext/node/polyfills/os.ts
+++ b/ext/node/polyfills/os.ts
@@ -129,6 +129,8 @@ export function arch(): string {
(type as any)[Symbol.toPrimitive] = (): string => type();
// deno-lint-ignore no-explicit-any
(uptime as any)[Symbol.toPrimitive] = (): number => uptime();
+// deno-lint-ignore no-explicit-any
+(machine as any)[Symbol.toPrimitive] = (): string => machine();
export function cpus(): CPUCoreInfo[] {
return ops.op_cpus();
@@ -247,6 +249,15 @@ export function version(): string {
return Deno.osRelease();
}
+/** Returns the machine type as a string */
+export function machine(): string {
+ if (Deno.build.arch == "aarch64") {
+ return "arm64";
+ }
+
+ return Deno.build.arch;
+}
+
/** Not yet implemented */
export function setPriority(pid: number, priority?: number) {
/* The node API has the 'pid' as the first parameter and as optional.
@@ -373,6 +384,7 @@ export default {
hostname,
loadavg,
networkInterfaces,
+ machine,
platform,
release,
setPriority,