deno_core
can provide ECMAScript built-ins but doesn’t expose Web APIs or Deno-specific APIs directly. You can either manually import Web APIs (like setTimeout
, performance
) or use Deno’s runtime in combination with deno_core
to provide them.
Use Deno’s permission system to manage access to sensitive operations. For example:
const permission = await Deno.permissions.query({ name: "read", path: "./file.txt" });
if (permission.state === "granted") {
// Allow access
}
Use FFI to call Rust functions from JS via deno_core
. Create a Rust extension and interface with it in JS:
#[op_sync]
fn my_rust_function() -> String {
"Hello from Rust!".to_string()
}
const result = await rustExtension.my_rust_function();
console.log(result); // "Hello from Rust!"
Run JS plugins with Deno's permission model, and interface with both Deno’s system APIs and Web APIs. Use deno_core
for managing execution and permissions.