aboutsummaryrefslogtreecommitdiff
path: root/lib/js_lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/js_lib')
-rwxr-xr-xlib/js_lib/array.ml14
-rwxr-xr-xlib/js_lib/dune9
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/js_lib/array.ml b/lib/js_lib/array.ml
new file mode 100755
index 0000000..e55f1e9
--- /dev/null
+++ b/lib/js_lib/array.ml
@@ -0,0 +1,14 @@
+open Js_of_ocaml
+
+(** Compare two arrays *)
+let compare
+ : f:('a -> 'a -> bool Js.t) -> 'a Js.js_array Js.t -> 'a Js.js_array Js.t -> bool Js.t
+ = fun ~f arr1 arr2 ->
+ if arr1##.length <> arr2##.length then
+ Js._false
+ else
+ arr1##every
+ (Js.wrap_callback @@ fun elem i _ ->
+ Js.Optdef.case (Js.array_get arr2 i)
+ (fun () -> Js._false)
+ (fun elem2 -> f elem elem2))
diff --git a/lib/js_lib/dune b/lib/js_lib/dune
new file mode 100755
index 0000000..131a4bf
--- /dev/null
+++ b/lib/js_lib/dune
@@ -0,0 +1,9 @@
+(library
+ (name js_lib)
+ (libraries
+ brr
+ brr.note
+ js_of_ocaml
+ )
+ (preprocess (pps js_of_ocaml-ppx))
+)