diff options
-rw-r--r-- | std/node/os.ts | 11 | ||||
-rw-r--r-- | std/node/os_test.ts | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/std/node/os.ts b/std/node/os.ts index 51e5bbd93..39209b4b7 100644 --- a/std/node/os.ts +++ b/std/node/os.ts @@ -89,6 +89,17 @@ interface UserInfo { homedir: string; } +arch[Symbol.toPrimitive] = (): string => arch(); +endianness[Symbol.toPrimitive] = (): string => endianness(); +freemem[Symbol.toPrimitive] = (): number => freemem(); +homedir[Symbol.toPrimitive] = (): string | null => homedir(); +hostname[Symbol.toPrimitive] = (): string | null => hostname(); +platform[Symbol.toPrimitive] = (): string => platform(); +release[Symbol.toPrimitive] = (): string => release(); +totalmem[Symbol.toPrimitive] = (): number => totalmem(); +type[Symbol.toPrimitive] = (): string => type(); +uptime[Symbol.toPrimitive] = (): number => uptime(); + /** Returns the operating system CPU architecture for which the Deno binary was compiled */ export function arch(): string { return Deno.build.arch; diff --git a/std/node/os_test.ts b/std/node/os_test.ts index f825ae192..2ceff79a4 100644 --- a/std/node/os_test.ts +++ b/std/node/os_test.ts @@ -175,6 +175,17 @@ test({ }); test({ + name: "Primitive coercion works as expected", + fn() { + assertEquals(`${os.arch}`, os.arch()); + assertEquals(`${os.endianness}`, os.endianness()); + assertEquals(`${os.homedir}`, os.homedir()); + assertEquals(`${os.hostname}`, os.hostname()); + assertEquals(`${os.platform}`, os.platform()); + } +}); + +test({ name: "APIs not yet implemented", fn() { assertThrows( |