mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 03:54:21 +01:00
bindings/wasm: Fix conversion to JsValue
This commit is contained in:
@@ -71,7 +71,8 @@ impl Statement {
|
||||
Ok(limbo_core::RowResult::Row(row)) => {
|
||||
let row_array = js_sys::Array::new();
|
||||
for value in row.values {
|
||||
row_array.push(&JsValue::from_str(&value.to_string()));
|
||||
let value = to_js_value(value);
|
||||
row_array.push(&value);
|
||||
}
|
||||
array.push(&row_array);
|
||||
}
|
||||
@@ -84,6 +85,22 @@ impl Statement {
|
||||
}
|
||||
}
|
||||
|
||||
fn to_js_value(value: limbo_core::Value) -> JsValue {
|
||||
match value {
|
||||
limbo_core::Value::Null => JsValue::null(),
|
||||
limbo_core::Value::Integer(i) => {
|
||||
if i >= i32::MIN as i64 && i <= i32::MAX as i64 {
|
||||
JsValue::from(i as i32)
|
||||
} else {
|
||||
JsValue::from(i)
|
||||
}
|
||||
}
|
||||
limbo_core::Value::Float(f) => JsValue::from(f),
|
||||
limbo_core::Value::Text(t) => JsValue::from_str(t),
|
||||
limbo_core::Value::Blob(b) => js_sys::Uint8Array::from(b.as_slice()).into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub struct File {
|
||||
vfs: VFS,
|
||||
fd: i32,
|
||||
|
||||
Reference in New Issue
Block a user