/// Import a module by filename.
Import a module by filename.
Import a module by filename .
pub fn import(&mut self, filename: &str) -> Result<(), String> {
        let scope = &mut self.handle_scope();
        let loader = module::Loader::new();
        let mut cwd = std::env::current_dir().unwrap();
        cwd.push("jstime");
        let cwd = cwd.into_os_string().into_string().unwrap();
        let res = match loader.import(scope, &cwd, filename) {
            Ok(res) => res,
            Err(e) => return Err(e.to_string(scope).unwrap().to_rust_string_lossy(scope)),
        };
        while builtins::tick(scope) {}
        // let resolver_global = scope
        //     .remove_slot::<v8::Global<v8::PromiseResolver>>()
        //     .unwrap();
        // let resolver = resolver_global.open(scope);
        // let null = v8::null(scope);
        // resolver.resolve(scope, null.into());
        // let promise = unsafe { v8::Local::<v8::Promise>::cast(res) };
        // println!("{:?}", promise.state());
        // // let resolver = unsafe { resolver_global.get_unchecked() };
        // // resolver.resolve(scope);
        // promise.result(scope);
        Ok(())
    }
pub fn import ( & mut self , filename : & str ) -> Result < ( ) , String > { let scope = & mut self . handle_scope ( ) ; let loader = module :: Loader :: new ( ) ; let mut cwd = std :: env :: current_dir ( ) . unwrap ( ) ; cwd . push ( " " ) ; let cwd = cwd . into_os_string ( ) . into_string ( ) . unwrap ( ) ; let res = match loader . import ( scope , & cwd , filename ) { Ok ( res ) => res , Err ( e ) => return Err ( e . to_string ( scope ) . unwrap ( ) . to_rust_string_lossy ( scope ) ) , } ; while builtins :: tick ( scope ) { } // let resolver_global = scope //     .remove_slot::<v8::Global<v8::PromiseResolver>>() //     .unwrap(); // let resolver = resolver_global.open(scope); // let null = v8::null(scope); // resolver.resolve(scope, null.into()); // let promise = unsafe { v8::Local::<v8::Promise>::cast(res) }; // println!("{:?}", promise.state()); // // let resolver = unsafe { resolver_global.get_unchecked() }; // // resolver.resolve(scope); // promise.result(scope); Ok ( ( ) ) }
Import a module by filename.
Import a module by filename .
&mut self
filename
&str