1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::{class::fs::Dirent, interface::AsyncIterator};
use js_sys::{Function, JsString, Object, Promise};
use wasm_bindgen::prelude::*;

#[wasm_bindgen(module = "fs")]
extern {
    #[wasm_bindgen(extends = Object, extends = AsyncIterator)]
    #[derive(Clone, Debug)]
    pub type Dir;

    // FIXME: event overloads

    //******************//
    // Instance Methods //
    //******************//

    #[wasm_bindgen(method)]
    pub fn close(this: &Dir, callback: Option<&Function>) -> Promise;

    #[wasm_bindgen(method, js_name = "closeSync")]
    pub fn close_sync(this: &Dir);

    #[wasm_bindgen(method)]
    pub fn read(this: &Dir) -> Promise;

    #[wasm_bindgen(method, js_name = "readSync")]
    pub fn read_sync(this: &Dir) -> Dirent;

    //*********************//
    // Instance Properties //
    //*********************//

    #[wasm_bindgen(method, getter)]
    pub fn path(this: &Dir) -> JsString;
}