Function quickjs_runtime::features::set_timeout::init

source ·
pub fn init(q_js_rt: &QuickJsRuntimeAdapter) -> Result<(), JsError>
Expand description

provides the setImmediate methods for the runtime

§Example

use quickjs_runtime::builder::QuickJsRuntimeBuilder;
use quickjs_runtime::jsutils::Script;
use std::time::Duration;
let rt = QuickJsRuntimeBuilder::new().build();
rt.eval_sync(None, Script::new("test_timeout.es", "setTimeout(() => {console.log('timed logging')}, 1000);")).expect("script failed");
std::thread::sleep(Duration::from_secs(2));