From 7ce2b58bcf412924464578f3469c210b34894c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Tue, 27 Dec 2022 00:16:12 +0100 Subject: feat(unstable): Add "Deno.osUptime()" API (#17179) This PR adds support for `Deno.osUptime` which reports number of seconds since os was booted. It will allow us to be compatible with Node's `os.uptime` - https://nodejs.org/api/os.html#osuptime Partially based on https://docs.rs/uptime_lib/latest/src/uptime_lib/lib.rs.html --- runtime/js/30_os.js | 5 +++++ runtime/js/90_deno_ns.js | 1 + 2 files changed, 6 insertions(+) (limited to 'runtime/js') diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 723b52132..3c9768593 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -25,6 +25,10 @@ return ops.op_os_release(); } + function osUptime() { + return ops.op_os_uptime(); + } + function systemMemoryInfo() { return ops.op_system_memory_info(); } @@ -106,6 +110,7 @@ loadavg, networkInterfaces, osRelease, + osUptime, setExitHandler, systemMemoryInfo, uid, diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 94a611456..f49fb5af1 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -119,6 +119,7 @@ refTimer: __bootstrap.timers.refTimer, unrefTimer: __bootstrap.timers.unrefTimer, osRelease: __bootstrap.os.osRelease, + osUptime: __bootstrap.os.osUptime, hostname: __bootstrap.os.hostname, systemMemoryInfo: __bootstrap.os.systemMemoryInfo, networkInterfaces: __bootstrap.os.networkInterfaces, -- cgit v1.2.3