package ezjs_min
A bunch of js_of_ocaml shortcuts
Install
Dune Dependency
Authors
Maintainers
Sources
0.3.0.tar.gz
md5=6475db585f4df50c079798ed0f028d87
sha512=10f851f60a169ae20898a286256b911faa83705a3a92f3aaa65fb0a5cb093710dbbc22d86140b03501f7e307dc4fbea0fced7448bc88c4e526b7e35ae4c474ec
doc/src/ezjs_min/table.ml.html
Source file table.ml
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 46
open Js type nonrec 'a t = < > t let obj = Unsafe.global##._Object let create () : 'a t = new%js obj let add (t : 'a t) (k : string) (v : 'a) = Unsafe.set t (string k) v let add_list (t : 'a t) (l : (string * 'a) list) = List.iter (fun (k, v) -> add t k v) l let add_listf (t : 'b t) (f : ('a -> 'b)) (l : (string * 'a) list) = List.iter (fun (k, v) -> add t k (f v)) l let make (l : (string * 'a) list) : 'a t = let t = create () in add_list t l; t let makef (f : ('a -> 'b)) (l : (string * 'a) list) : 'b t = let t = create () in add_listf t f l; t let remove (t : 'a t) (k : string) = Unsafe.delete t (string k) let find (t : 'a t) (k : string) : 'a option = Optdef.to_option (Unsafe.get t (string k)) let keys (t : 'a t) : string list = to_listf to_string @@ obj##keys t let items (t : 'a t) : (string * 'a) list = to_listf (fun k -> to_string k, Unsafe.get t k) @@ obj##keys t let itemsf (f : ('a -> 'b)) (t : 'a t) : (string * 'b) list = to_listf (fun k -> to_string k, f @@ Unsafe.get t k) @@ obj##keys t let length (t : 'a t) = (obj##keys t)##.length let merge (l : 'a t list) : 'a t = let t = create () in List.iter (fun x -> List.iter (fun (k, v) -> add t k v) (items x)) l; t
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>