diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-14 12:35:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 12:35:38 +0100 |
commit | 201737c518237b271b5bbbd8e2b1fd19ce51fdd9 (patch) | |
tree | 49a4da83ee9c6cdb7a9798f3d6f1430e027913c0 | |
parent | 2502a37d41e8a7f279af74d7dacc009ee1010f67 (diff) |
feat: stabilize Deno.osUptime() (#17554)
This commit stabilizes "Deno.osUptime()" API. The "--unstable" flag is
no longer required to use this API.
-rw-r--r-- | cli/tsc/dts/lib.deno.ns.d.ts | 14 | ||||
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 15 | ||||
-rw-r--r-- | runtime/js/30_os.js | 8 | ||||
-rw-r--r-- | runtime/js/99_main.js | 4 | ||||
-rw-r--r-- | runtime/ops/os/mod.rs | 1 |
5 files changed, 17 insertions, 25 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 93e1b54a6..154b5f15f 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -447,6 +447,20 @@ declare namespace Deno { export function osRelease(): string; /** + * Returns the Operating System uptime in number of seconds. + * + * ```ts + * console.log(Deno.osUptime()); + * ``` + * + * Requires `allow-sys` permission. + * + * @tags allow-sys + * @category Runtime Environment + */ + export function osUptime(): number; + + /** * Options which define the permissions within a test or worker context. * * `"inherit"` ensures that all permissions of the parent process will be diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index e2abab26d..822425d05 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1406,21 +1406,6 @@ declare namespace Deno { * @category HTTP Server */ export function upgradeHttpRaw(request: Request): [Deno.Conn, Uint8Array]; - - /** **UNSTABLE**: New API, yet to be vetted. - * - * Returns the Operating System uptime in number of seconds. - * - * ```ts - * console.log(Deno.osUptime()); - * ``` - * - * Requires `allow-sys` permission. - * - * @tags allow-sys - * @category Runtime Environment - */ - export function osUptime(): number; } /** **UNSTABLE**: New API, yet to be vetted. diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index b09f25797..63e3748d3 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -25,10 +25,8 @@ function osRelease() { return ops.op_os_release(); } -function createOsUptime(opFn) { - return function osUptime() { - return opFn(); - }; +function osUptime() { + return ops.op_os_uptime(); } function systemMemoryInfo() { @@ -107,7 +105,6 @@ function execPath() { } export { - createOsUptime, env, execPath, exit, @@ -116,6 +113,7 @@ export { loadavg, networkInterfaces, osRelease, + osUptime, setExitHandler, systemMemoryInfo, uid, diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index cfddb143d..fa9b0a20d 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -471,7 +471,6 @@ function bootstrapMainRuntime(runtimeOptions) { ops.op_node_unstable_net_listen_udp, ops.op_node_unstable_net_listen_unixpacket, ), - osUptime: os.createOsUptime(ops.op_node_unstable_os_uptime), }, }); @@ -508,7 +507,6 @@ function bootstrapMainRuntime(runtimeOptions) { ops.op_net_listen_udp, ops.op_net_listen_unixpacket, ), - osUptime: os.createOsUptime(ops.op_os_uptime), }); } @@ -602,7 +600,6 @@ function bootstrapWorkerRuntime( ops.op_node_unstable_net_listen_udp, ops.op_node_unstable_net_listen_unixpacket, ), - osUptime: os.createOsUptime(ops.op_node_unstable_os_uptime), }, }); @@ -631,7 +628,6 @@ function bootstrapWorkerRuntime( ops.op_net_listen_udp, ops.op_net_listen_unixpacket, ), - osUptime: os.createOsUptime(ops.op_os_uptime), }); } ObjectDefineProperties(finalDenoNs, { diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs index f970c318b..020634c32 100644 --- a/runtime/ops/os/mod.rs +++ b/runtime/ops/os/mod.rs @@ -419,7 +419,6 @@ fn os_uptime(state: &mut OpState) -> Result<u64, AnyError> { #[op] fn op_os_uptime(state: &mut OpState) -> Result<u64, AnyError> { - super::check_unstable(state, "Deno.osUptime"); os_uptime(state) } |