diff --git a/lib/d3.ml b/lib/d3.ml index eba7a26..b06500e 100644 --- a/lib/d3.ml +++ b/lib/d3.ml @@ -79,6 +79,7 @@ let exit : ('a, 'a) t = thunk_call "exit" let filter f = const_call "filter" (mb (fun this d i () -> Js.bool (f this d i))) let sort f = const_call "sort" f +let each f = const_call "each" (mb (fun this d i () -> (f this d i))) let str f name x = f name (fun _ _ _ -> x) let int f name x = str f name (string_of_int x) diff --git a/lib/d3.mli b/lib/d3.mli index dcc59ff..c54822a 100644 --- a/lib/d3.mli +++ b/lib/d3.mli @@ -196,12 +196,17 @@ val filter : ('a, bool) fn -> ('a, 'a) t {{:https://github.com/mbostock/d3/wiki/Selections#filter}D3.js docs} *) -val sort : ('a -> 'a -> int) -> ('a, 'a) t +val sort : ('a -> 'a -> int) -> ('a, 'a) t (** [sort f] sorts the elements in the current selection according to the comparator function, and then re-inserts the document elements to match. {{:https://github.com/mbostock/d3/wiki/Selections#sort}D3.js docs} *) +val each : ('a, unit) fn -> ('a, 'a) t +(** [each f] invokes [f] for each element in the current selection. + + {{:https://github.com/mbostock/d3/wiki/Selections#each}D3.js docs} *) + (** {2 Composition operators} *) val (|.) : ('a, 'b) t -> ('b, 'c) t -> ('a, 'c) t