PHP-Deno

JsRuntime
in package

The JsRuntime is a wrapper around a V8 isolate. It can execute ES6 including ES6 modules. The JsRuntime does not include any of the Deno.core.* ops, and does not provide implementations for web apis, such as fetch(). Use JsRuntime if you want to provide low-level v8 isolates, and implement extensions for all functionality such as local storage, remote requests etc.

Table of Contents

Methods

__construct()  : mixed
execute_script()  : mixed
Execute JavaSscript inside the V8 Isolate.
load_main_module()  : int
Load an ES6 module as the main starting module.
mod_evaluate()  : mixed
Evaluate a given module ID. This will run all schyonous code in the module.
run_event_loop()  : mixed
Wait for the event loop to run all pending async actions.
snapshot()  : string
Takes a snapshot. The isolate should have been created with will_snapshot set to true.

Methods

execute_script()

Execute JavaSscript inside the V8 Isolate.

public execute_script(string $name, string $source_code) : mixed

This does not support top level await for Es6 imports. use load_main_module to execute JavaScript in modules.

Parameters
$name : string
$source_code : string

load_main_module()

Load an ES6 module as the main starting module.

public load_main_module(string $specifier, string|null $code) : int

This function returns a module ID which should be passed to mod_evaluate().

Parameters
$specifier : string
$code : string|null
Return values
int

mod_evaluate()

Evaluate a given module ID. This will run all schyonous code in the module.

public mod_evaluate(int $id) : mixed

If there are pending Promises or async axtions, use run_event_loop() to wait until all async actions complete.

Parameters
$id : int

run_event_loop()

Wait for the event loop to run all pending async actions.

public run_event_loop() : mixed

snapshot()

Takes a snapshot. The isolate should have been created with will_snapshot set to true.

public snapshot() : string
Return values
string

        
On this page

Search results