Skip to content

Commit 5175a31

Browse files
authored
Compatibility with Wasm_of_ocaml (#173)
* Explicit float conversions * Remove use of Ocaml physical equality In JavaScript, 'x === undefined' implies 'x == null'.
1 parent 2c72798 commit 5175a31

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/ojs.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ external int_to_js: int -> t = "%identity"
2727
external bool_of_js: t -> bool = "caml_js_to_bool"
2828
external bool_to_js: bool -> t = "caml_js_from_bool"
2929

30-
external float_of_js: t -> float = "%identity"
31-
external float_to_js: float -> t = "%identity"
30+
external float_of_js: t -> float = "caml_js_to_float"
31+
external float_to_js: float -> t = "caml_js_from_float"
3232

3333
external obj: (string * t) array -> t = "caml_js_object"
3434

@@ -91,7 +91,7 @@ let list_to_js f l =
9191
array_to_js f (Array.of_list l)
9292

9393
let option_of_js f x =
94-
if equals x null || x == undefined then None
94+
if equals x null then None
9595
else Some (f x)
9696

9797
let option_to_js f = function

lib/ojs.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ external int_to_js: int -> t = "%identity"
2121
external bool_of_js: t -> bool = "caml_js_to_bool"
2222
external bool_to_js: bool -> t = "caml_js_from_bool"
2323

24-
external float_of_js: t -> float = "%identity"
25-
external float_to_js: float -> t = "%identity"
24+
external float_of_js: t -> float = "caml_js_to_float"
25+
external float_to_js: float -> t = "caml_js_from_float"
2626

2727
val array_of_js: (t -> 'a) -> t -> 'a array
2828
val array_to_js: ('a -> t) -> 'a array -> t

0 commit comments

Comments
 (0)