1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

loadavg and osRelease made unstable (#4938)

This commit is contained in:
Ryan Dahl 2020-04-27 18:00:19 -04:00 committed by GitHub
parent 95a08857f1
commit f2d5e6f58a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -97,6 +97,9 @@ declare namespace Deno {
* console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
*
* Requires `allow-env` permission.
*
* **Unstable** There are questions around which permission this needs. And
* maybe should be renamed (loadAverage?)
*/
export function loadavg(): number[];
@ -113,6 +116,9 @@ declare namespace Deno {
* console.log(Deno.osRelease());
*
* Requires `allow-env` permission.
*
* **Unstable** new API maybe move to Deno.build or Deno.versions? Depends on
* sys-info, which we don't necessarally want to depend on.
*/
export function osRelease(): string;

View file

@ -156,6 +156,7 @@ fn op_loadavg(
_args: Value,
_zero_copy: Option<ZeroCopyBuf>,
) -> Result<JsonOp, OpError> {
state.check_unstable("Deno.loadavg");
state.check_env()?;
match sys_info::loadavg() {
Ok(loadavg) => Ok(JsonOp::Sync(json!([
@ -182,6 +183,7 @@ fn op_os_release(
_args: Value,
_zero_copy: Option<ZeroCopyBuf>,
) -> Result<JsonOp, OpError> {
state.check_unstable("Deno.osRelease");
state.check_env()?;
let release = sys_info::os_release().unwrap_or_else(|_| "".to_string());
Ok(JsonOp::Sync(json!(release)))