summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Ihrig <cjihrig@gmail.com>2022-10-25 11:21:14 -0400
committerGitHub <noreply@github.com>2022-10-25 11:21:14 -0400
commit606db35ccbe8e3c1ce93ae943a2f9850558400af (patch)
tree48123d79982e74a5be8c0679c6f1a7ef9abe2df1
parentf242d98280a7b261af9bf458498915d973f8d48e (diff)
feat: stabilize Deno.loadavg() (#16412)
-rw-r--r--cli/diagnostics.rs1
-rw-r--r--cli/dts/lib.deno.ns.d.ts18
-rw-r--r--cli/dts/lib.deno.unstable.d.ts21
-rw-r--r--cli/tests/testdata/run/unstable.js2
-rw-r--r--cli/tests/testdata/run/unstable.ts2
-rw-r--r--cli/tests/testdata/run/unstable_disabled.out6
-rw-r--r--cli/tests/testdata/run/unstable_enabled.out2
-rw-r--r--cli/tests/testdata/run/unstable_enabled_js.out2
-rw-r--r--runtime/js/90_deno_ns.js2
-rw-r--r--runtime/ops/os.rs1
10 files changed, 26 insertions, 31 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs
index e0ac5e0b7..4e456b444 100644
--- a/cli/diagnostics.rs
+++ b/cli/diagnostics.rs
@@ -42,7 +42,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"kill",
"listen",
"listenDatagram",
- "loadavg",
"dlopen",
"osRelease",
"ppid",
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 34d85ac87..ed6e8ad4f 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -314,6 +314,24 @@ declare namespace Deno {
*/
export function hostname(): string;
+ /**
+ * Returns an array containing the 1, 5, and 15 minute load averages. The
+ * load average is a measure of CPU and IO utilization of the last one, five,
+ * and 15 minute periods expressed as a fractional number. Zero means there
+ * is no load. On Windows, the three values are always the same and represent
+ * the current load, not the 1, 5 and 15 minute load averages.
+ *
+ * ```ts
+ * console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
+ * ```
+ *
+ * Requires `allow-sys` permission.
+ *
+ * @tags allow-sys
+ * @category Observability
+ */
+ export function loadavg(): number[];
+
/** Reflects the `NO_COLOR` environment variable at program start.
*
* When the value is `true`, the Deno CLI will attempt to not send color codes
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index 85b5911f8..1085c7039 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -245,27 +245,6 @@ declare namespace Deno {
/** **UNSTABLE**: New API, yet to be vetted.
*
- * Returns an array containing the 1, 5, and 15 minute load averages. The
- * load average is a measure of CPU and IO utilization of the last one, five,
- * and 15 minute periods expressed as a fractional number. Zero means there
- * is no load. On Windows, the three values are always the same and represent
- * the current load, not the 1, 5 and 15 minute load averages.
- *
- * ```ts
- * console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
- * ```
- *
- * Requires `allow-sys` permission.
- * There are questions around which permission this needs. And maybe should be
- * renamed (loadAverage?).
- *
- * @tags allow-sys
- * @category Observability
- */
- export function loadavg(): number[];
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
* Returns the release version of the Operating System.
*
* ```ts
diff --git a/cli/tests/testdata/run/unstable.js b/cli/tests/testdata/run/unstable.js
index a9894be3e..8c01b214e 100644
--- a/cli/tests/testdata/run/unstable.js
+++ b/cli/tests/testdata/run/unstable.js
@@ -1 +1 @@
-console.log(Deno.loadavg);
+console.log(Deno.umask);
diff --git a/cli/tests/testdata/run/unstable.ts b/cli/tests/testdata/run/unstable.ts
index a9894be3e..8c01b214e 100644
--- a/cli/tests/testdata/run/unstable.ts
+++ b/cli/tests/testdata/run/unstable.ts
@@ -1 +1 @@
-console.log(Deno.loadavg);
+console.log(Deno.umask);
diff --git a/cli/tests/testdata/run/unstable_disabled.out b/cli/tests/testdata/run/unstable_disabled.out
index 28659645d..f3de913e6 100644
--- a/cli/tests/testdata/run/unstable_disabled.out
+++ b/cli/tests/testdata/run/unstable_disabled.out
@@ -1,5 +1,5 @@
[WILDCARD]
-error: TS2339 [ERROR]: Property 'loadavg' does not exist on type 'typeof Deno'. 'Deno.loadavg' is an unstable API. Did you forget to run with the '--unstable' flag?
-console.log(Deno.loadavg);
- ~~~~~~~
+error: TS2339 [ERROR]: Property 'umask' does not exist on type 'typeof Deno'. 'Deno.umask' is an unstable API. Did you forget to run with the '--unstable' flag?
+console.log(Deno.umask);
+ ~~~~~
at [WILDCARD]/unstable.ts:1:18
diff --git a/cli/tests/testdata/run/unstable_enabled.out b/cli/tests/testdata/run/unstable_enabled.out
index b4cedce14..5f88c778c 100644
--- a/cli/tests/testdata/run/unstable_enabled.out
+++ b/cli/tests/testdata/run/unstable_enabled.out
@@ -1 +1 @@
-[Function: loadavg]
+[Function: umask]
diff --git a/cli/tests/testdata/run/unstable_enabled_js.out b/cli/tests/testdata/run/unstable_enabled_js.out
index b4cedce14..5f88c778c 100644
--- a/cli/tests/testdata/run/unstable_enabled_js.out
+++ b/cli/tests/testdata/run/unstable_enabled_js.out
@@ -1 +1 @@
-[Function: loadavg]
+[Function: umask]
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 815173a25..b4440d2ac 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -89,6 +89,7 @@
seekSync: __bootstrap.files.seekSync,
connect: __bootstrap.net.connect,
listen: __bootstrap.net.listen,
+ loadavg: __bootstrap.os.loadavg,
connectTls: __bootstrap.tls.connectTls,
listenTls: __bootstrap.tls.listenTls,
startTls: __bootstrap.tls.startTls,
@@ -120,7 +121,6 @@
__bootstrap.denoNsUnstable = {
consoleSize: __bootstrap.tty.consoleSize,
DiagnosticCategory: __bootstrap.diagnostics.DiagnosticCategory,
- loadavg: __bootstrap.os.loadavg,
osRelease: __bootstrap.os.osRelease,
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
networkInterfaces: __bootstrap.os.networkInterfaces,
diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs
index 0c171d710..f774e1f2e 100644
--- a/runtime/ops/os.rs
+++ b/runtime/ops/os.rs
@@ -160,7 +160,6 @@ fn op_exit(state: &mut OpState) {
#[op]
fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> {
- super::check_unstable(state, "Deno.loadavg");
state
.borrow_mut::<Permissions>()
.sys