|
1 | 1 | use crate::Context; |
2 | 2 | use crate::Value; |
3 | 3 |
|
4 | | -pub fn println(values: Vec<Value>, context: &Context) -> Result<Value, String> { |
5 | | - match format(values, context) { |
6 | | - error @ Err(_) => error, |
7 | | - Ok(value) => { |
8 | | - println!("{value}"); |
9 | | - Ok(Value::Null) |
| 4 | +#[cfg(feature = "univ")] |
| 5 | +pub use univ::*; |
| 6 | +#[cfg(feature = "univ")] |
| 7 | +mod univ { |
| 8 | + use super::format; |
| 9 | + use crate::Context; |
| 10 | + use crate::Value; |
| 11 | + |
| 12 | + pub fn println(values: Vec<Value>, context: &Context) -> Result<Value, String> { |
| 13 | + match format(values, context) { |
| 14 | + error @ Err(_) => error, |
| 15 | + Ok(value) => { |
| 16 | + println!("{value}"); |
| 17 | + Ok(Value::Null) |
| 18 | + } |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | + pub fn print(values: Vec<Value>, context: &Context) -> Result<Value, String> { |
| 23 | + match format(values, context) { |
| 24 | + error @ Err(_) => error, |
| 25 | + Ok(value) => { |
| 26 | + print!("{value}"); |
| 27 | + Ok(Value::Null) |
| 28 | + } |
10 | 29 | } |
11 | 30 | } |
12 | 31 | } |
13 | 32 |
|
14 | | -pub fn print(values: Vec<Value>, context: &Context) -> Result<Value, String> { |
15 | | - match format(values, context) { |
16 | | - error @ Err(_) => error, |
17 | | - Ok(value) => { |
18 | | - print!("{value}"); |
19 | | - Ok(Value::Null) |
| 33 | +#[cfg(feature = "wasm")] |
| 34 | +pub use wasm::*; |
| 35 | +#[cfg(feature = "wasm")] |
| 36 | +mod wasm { |
| 37 | + use super::format; |
| 38 | + use crate::Context; |
| 39 | + use crate::Value; |
| 40 | + use wasm_bindgen::prelude::wasm_bindgen; |
| 41 | + |
| 42 | + #[wasm_bindgen] |
| 43 | + extern "C" { |
| 44 | + #[wasm_bindgen(js_name = appendOutput)] |
| 45 | + fn append_output(output: &str); |
| 46 | + } |
| 47 | + |
| 48 | + pub fn println(values: Vec<Value>, context: &Context) -> Result<Value, String> { |
| 49 | + match format(values, context) { |
| 50 | + error @ Err(_) => error, |
| 51 | + Ok(value) => { |
| 52 | + append_output(format!("{value}\r\n").as_str()); |
| 53 | + Ok(Value::Null) |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + pub fn print(values: Vec<Value>, context: &Context) -> Result<Value, String> { |
| 59 | + match format(values, context) { |
| 60 | + error @ Err(_) => error, |
| 61 | + Ok(value) => { |
| 62 | + append_output(format!("{value}").as_str()); |
| 63 | + Ok(Value::Null) |
| 64 | + } |
20 | 65 | } |
21 | 66 | } |
22 | 67 | } |
|
0 commit comments