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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crate::class::stream;
use js_sys::Object;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct ConsoleConstructorOptions {
    stdout: stream::Writable,
    stderr: stream::Writable,
    ignore_errors: Option<bool>,
    color_mod: JsValue,
    inspect_options: Option<Object>,
}

#[wasm_bindgen]
impl ConsoleConstructorOptions {
    #[wasm_bindgen(constructor)]
    pub fn new_with_values(
        stdout: stream::Writable,
        stderr: stream::Writable,
        ignore_errors: Option<bool>,
        color_mod: JsValue,
        inspect_options: Option<Object>,
    ) -> ConsoleConstructorOptions {
        ConsoleConstructorOptions {
            stdout,
            stderr,
            ignore_errors,
            color_mod,
            inspect_options,
        }
    }

    pub fn new(stdout: stream::Writable, stderr: stream::Writable) -> ConsoleConstructorOptions {
        let ignore_errors = Default::default();
        let color_mod = JsValue::UNDEFINED;
        let inspect_options = Default::default();
        ConsoleConstructorOptions::new_with_values(stdout, stderr, ignore_errors, color_mod, inspect_options)
    }

    #[wasm_bindgen(getter)]
    pub fn stdout(&self) -> stream::Writable {
        self.stdout.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_stdout(&mut self, value: stream::Writable) {
        self.stdout = value;
    }

    #[wasm_bindgen(getter)]
    pub fn stderr(&self) -> stream::Writable {
        self.stderr.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_stderr(&mut self, value: stream::Writable) {
        self.stderr = value;
    }

    #[wasm_bindgen(getter)]
    pub fn ignore_errors(&self) -> Option<bool> {
        self.ignore_errors
    }

    #[wasm_bindgen(setter)]
    pub fn set_ignore_errors(&mut self, value: Option<bool>) {
        self.ignore_errors = value;
    }

    #[wasm_bindgen(getter)]
    pub fn color_mod(&self) -> JsValue {
        self.color_mod.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_color_mod(&mut self, value: JsValue) {
        self.color_mod = value;
    }

    #[wasm_bindgen(getter)]
    pub fn inspect_options(&self) -> Option<Object> {
        self.inspect_options.clone()
    }

    #[wasm_bindgen(setter)]
    pub fn set_inspect_options(&mut self, value: Option<Object>) {
        self.inspect_options = value;
    }
}