1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

feat: stabilize Deno.osUptime() (#17554)

This commit stabilizes "Deno.osUptime()" API. The "--unstable" flag is
no longer required to use this API.
This commit is contained in:
Bartek Iwańczuk 2023-02-14 12:35:38 +01:00 committed by GitHub
parent 2502a37d41
commit 201737c518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 25 deletions

View file

@ -446,6 +446,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.
*

View file

@ -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.

View file

@ -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,

View file

@ -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, {

View file

@ -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)
}