#deno #core #tokio #v8

deno_core

A secure JavaScript/TypeScript runtime built with V8, Rust, and Tokio

67 breaking releases

new 0.95.0 Jul 26, 2021
0.93.0 Jul 12, 2021
0.82.0 Mar 21, 2021
0.75.0 Dec 30, 2020
0.0.1 Sep 13, 2019

#64 in Web programming

Download history 995/week @ 2021-04-05 1187/week @ 2021-04-12 1373/week @ 2021-04-19 1688/week @ 2021-04-26 755/week @ 2021-05-03 1050/week @ 2021-05-10 1470/week @ 2021-05-17 1275/week @ 2021-05-24 1403/week @ 2021-05-31 1779/week @ 2021-06-07 2573/week @ 2021-06-14 1805/week @ 2021-06-21 2369/week @ 2021-06-28 2182/week @ 2021-07-05 2758/week @ 2021-07-12 2852/week @ 2021-07-19

7,897 downloads per month
Used in 37 crates (35 directly)

MIT license

4.5MB
11K SLoC

Rust 9K SLoC // 0.1% comments TypeScript 1K SLoC // 0.1% comments JavaScript 832 SLoC // 0.2% comments

Deno Core Crate

crates docs

The main dependency of this crate is rusty_v8, which provides the V8-Rust bindings.

This Rust crate contains the essential V8 bindings for Deno's command-line interface (Deno CLI). The main abstraction here is the JsRuntime which provides a way to execute JavaScript.

The JsRuntime implements an event loop abstraction for the executed code that keeps track of all pending tasks (async ops, dynamic module loads). It is user's responsibility to drive that loop by using JsRuntime::run_event_loop method - it must be executed in the context of Rust's future executor (eg. tokio, smol).

In order to bind Rust functions into JavaScript, use the Deno.core.opSync() and Deno.core.opAsync() functions to trigger the "op_fn" callback in JsRuntime::register_op on Rust side. A conventional way to handle "op_fn" callbacks is to use the op_sync and op_async functions.

Documentation for this crate is thin at the moment. Please see hello_world.rs and http_bench_json_ops.rs as examples of usage.

TypeScript support and lots of other functionality are not available at this layer. See the CLI for that.

Dependencies

~50MB
~1M SLoC