aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-04-09 10:57:49 +0200
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:01:12 +0100
commitb941c8c059012d6497553f564fe3cb5cd7b6f75c (patch)
tree44f2494a1d2ad280487ab338dfd54a0a52e213cf /lib
parent298ddbaaf440e7bfa3cec27956c482ea44bea173 (diff)
Update build
Diffstat (limited to '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))
+)