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
//! Cloudflare D1 helpers shared by worker crates.
//!
//! Both `nostr-bbs-auth-worker` and `nostr-bbs-relay-worker` frequently need
//! to convert Rust values into `JsValue` for D1 bind parameters. These tiny
//! helpers were duplicated 8+ times across the two crates. Centralising them
//! here eliminates that duplication without adding any new dependencies (core
//! already depends on `wasm-bindgen` for the wasm32 target).
use JsValue;
/// Convert a `&str` to a `JsValue::from_str`.
/// Convert an `Option<&str>` to a `JsValue`, mapping `None` to `JsValue::NULL`.
/// Convert an `f64` to a `JsValue::from_f64`.
/// Convert an `i64` to a `JsValue::from_f64` (JS numbers are always f64).
/// Convert an `Option<i64>` to a `JsValue`, mapping `None` to `JsValue::NULL`.