mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
feat(std/node): add os.totalmem, os.freemem (#8317)
This commit is contained in:
parent
723fbb8f68
commit
d5772a937b
2 changed files with 18 additions and 18 deletions
|
@ -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 */
|
||||
|
|
|
@ -200,6 +200,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() {
|
||||
|
@ -210,13 +224,6 @@ Deno.test({
|
|||
Error,
|
||||
"Not implemented",
|
||||
);
|
||||
assertThrows(
|
||||
() => {
|
||||
os.freemem();
|
||||
},
|
||||
Error,
|
||||
"Not implemented",
|
||||
);
|
||||
assertThrows(
|
||||
() => {
|
||||
os.getPriority();
|
||||
|
@ -238,13 +245,6 @@ Deno.test({
|
|||
Error,
|
||||
"Not implemented",
|
||||
);
|
||||
assertThrows(
|
||||
() => {
|
||||
os.totalmem();
|
||||
},
|
||||
Error,
|
||||
"Not implemented",
|
||||
);
|
||||
assertThrows(
|
||||
() => {
|
||||
os.type();
|
||||
|
|
Loading…
Reference in a new issue