diff options
author | Gyubong <jopemachine@naver.com> | 2020-11-19 21:56:32 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 07:56:32 -0500 |
commit | d5772a937b36379ca932e4083404460874419859 (patch) | |
tree | c6df553856f05a08281edd781347d81e9ae0258f /std/node | |
parent | 723fbb8f68eeaf6e5c14d9f8ac2c32f986ed60d9 (diff) |
feat(std/node): add os.totalmem, os.freemem (#8317)
Diffstat (limited to 'std/node')
-rw-r--r-- | std/node/_os.ts | 8 | ||||
-rw-r--r-- | std/node/os_test.ts | 28 |
2 files changed, 18 insertions, 18 deletions
diff --git a/std/node/_os.ts b/std/node/_os.ts index 773cca8bd..14bf20abd 100644 --- a/std/node/_os.ts +++ b/std/node/_os.ts @@ -123,9 +123,9 @@ export function endianness(): "BE" | "LE" { return new Int16Array(buffer)[0] === 256 ? "LE" : "BE"; } -/** Not yet implemented */ +/** Return free memory amount */ export function freemem(): number { - notImplemented(SEE_GITHUB_ISSUE); + return Deno.systemMemoryInfo().free; } /** Not yet implemented */ @@ -185,9 +185,9 @@ export function tmpdir(): string | null { notImplemented(SEE_GITHUB_ISSUE); } -/** Not yet implemented */ +/** Return total physical memory amount */ export function totalmem(): number { - notImplemented(SEE_GITHUB_ISSUE); + return Deno.systemMemoryInfo().total; } /** Not yet implemented */ diff --git a/std/node/os_test.ts b/std/node/os_test.ts index e4231aa3c..8879f8345 100644 --- a/std/node/os_test.ts +++ b/std/node/os_test.ts @@ -201,6 +201,20 @@ Deno.test({ }); Deno.test({ + name: "Total memory amount should be greater than 0", + fn() { + assert(os.totalmem() > 0); + }, +}); + +Deno.test({ + name: "Free memory amount should be greater than 0", + fn() { + assert(os.freemem() > 0); + }, +}); + +Deno.test({ name: "APIs not yet implemented", fn() { assertThrows( @@ -212,13 +226,6 @@ Deno.test({ ); assertThrows( () => { - os.freemem(); - }, - Error, - "Not implemented", - ); - assertThrows( - () => { os.getPriority(); }, Error, @@ -240,13 +247,6 @@ Deno.test({ ); assertThrows( () => { - os.totalmem(); - }, - Error, - "Not implemented", - ); - assertThrows( - () => { os.type(); }, Error, |