mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix(ext/node): implement os.machine (#21751)
This commit is contained in:
parent
8e4feacd25
commit
9f7586a206
2 changed files with 23 additions and 0 deletions
|
@ -29,6 +29,17 @@ Deno.test({
|
|||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "os machine (arch)",
|
||||
fn() {
|
||||
if (Deno.build.arch == "aarch64") {
|
||||
assertEquals(os.machine(), "arm64");
|
||||
} else {
|
||||
assertEquals(os.machine(), Deno.build.arch);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "home directory is a string",
|
||||
fn() {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue