pub fn new() -> Self {
        // Initialize V8 for only once.
        static JS_INIT: Once = Once::new();
        JS_INIT.call_once(initialize_v8);

        let mut isolate = Isolate::new(CreateParams::default());

        let context: Global<Context> = {
            let scope = &mut HandleScope::new(&mut isolate);
            let context = {
                let globals = ObjectTemplate::new(scope);

                globals.set(
                    String::new(scope, "log").unwrap().into(),
                    FunctionTemplate::new(scope, Self::log_callback).into(),
                );

                globals.set(
                    String::new(scope, "peripherals").unwrap().into(),
                    PeripheralsStore::js_api(scope).into(),
                );

                Context::new_from_template(scope, globals)
            };

            Global::new(scope, context)
        };

        JsRuntime {
            isolate,
            context,
        }
    }
/// Creates a new JS runtime environment.
Creates a new JS runtime environment.
Creates a new JS runtime environment .
pub fn new() -> Self {
        // Initialize V8 for only once.
        static JS_INIT: Once = Once::new();
        JS_INIT.call_once(initialize_v8);
        let mut isolate = Isolate::new(CreateParams::default());
        let context: Global<Context> = {
            let scope = &mut HandleScope::new(&mut isolate);
            let context = {
                let globals = ObjectTemplate::new(scope);
                globals.set(
                    String::new(scope, "log").unwrap().into(),
                    FunctionTemplate::new(scope, Self::log_callback).into(),
                );
                globals.set(
                    String::new(scope, "peripherals").unwrap().into(),
                    PeripheralsStore::js_api(scope).into(),
                );
                Context::new_from_template(scope, globals)
            };
            Global::new(scope, context)
        };
        JsRuntime {
            isolate,
            context,
        }
    }
pub fn new ( ) -> Self { // Initialize V8 for only once. static JS_INIT : Once = Once :: new ( ) ; JS_INIT . call_once ( initialize_v8 ) ; let mut isolate = Isolate :: new ( CreateParams :: default ( ) ) ; let context : Global < Context > = { let scope = & mut HandleScope :: new ( & mut isolate ) ; let context = { let globals = ObjectTemplate :: new ( scope ) ; globals . set ( String :: new ( scope , " " ) . unwrap ( ) . into ( ) , FunctionTemplate :: new ( scope , Self :: log_callback ) . into ( ) , ) ; globals . set ( String :: new ( scope , " " ) . unwrap ( ) . into ( ) , PeripheralsStore :: js_api ( scope ) . into ( ) , ) ; Context :: new_from_template ( scope , globals ) } ; Global :: new ( scope , context ) } ; JsRuntime { isolate , context , } }
Creates a new JS runtime environment.
Creates a new JS runtime environment .