Skip to content

Commit

Permalink
runtime(js.{map,set,weakmap,weakset}): port @mel.send.pipe fns to @me…
Browse files Browse the repository at this point in the history
…l.send (#1274)
  • Loading branch information
anmonteiro authored Dec 27, 2024
1 parent 5c93c9c commit 174069f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
5 changes: 3 additions & 2 deletions jscomp/runtime/js_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ external set : ('k, 'v) t -> key:'k -> value:'v -> ('k, 'v) t = "set"
external clear : ('k, 'v) t -> unit = "clear" [@@mel.send]
external delete : ('k, 'v) t -> key:'k -> bool = "delete" [@@mel.send]

external forEach : f:(('v -> 'k -> ('k, 'v) t -> unit)[@mel.uncurry]) -> unit
external forEach :
f:(('v -> 'k -> ('k, 'v) t -> unit)[@mel.uncurry]) -> ('k, 'v) t -> unit
= "forEach"
[@@mel.send.pipe: ('k, 'v) t]
[@@mel.send]

external keys : ('k, 'v) t -> 'k Js.iterator = "keys" [@@mel.send]
external values : ('k, 'v) t -> 'v Js.iterator = "values" [@@mel.send]
Expand Down
12 changes: 6 additions & 6 deletions jscomp/runtime/js_set.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ external make : unit -> 'a t = "Set" [@@mel.new]
external fromArray : 'a array -> 'a t = "Set" [@@mel.new]
external toArray : 'a t -> 'a array = "Array.from"
external size : 'a t -> int = "size" [@@mel.get]
external add : value:'a -> 'a t = "add" [@@mel.send.pipe: 'a t]
external add : value:'a -> 'a t -> 'a t = "add" [@@mel.send]
external clear : 'a t -> unit = "clear" [@@mel.send]
external delete : value:'a -> bool = "delete" [@@mel.send.pipe: 'a t]
external forEach : f:('a -> unit) -> unit = "forEach" [@@mel.send.pipe: 'a t]
external has : value:'a -> bool = "has" [@@mel.send.pipe: 'a t]
external values : 'a Js.iterator = "values" [@@mel.send.pipe: 'a t]
external entries : ('a * 'a) Js.iterator = "entries" [@@mel.send.pipe: 'a t]
external delete : value:'a -> 'a t -> bool = "delete" [@@mel.send]
external forEach : f:('a -> unit) -> 'a t -> unit = "forEach" [@@mel.send]
external has : value:'a -> 'a t -> bool = "has" [@@mel.send]
external values : 'a t -> 'a Js.iterator = "values" [@@mel.send]
external entries : 'a t -> ('a * 'a) Js.iterator = "entries" [@@mel.send]

(*
external difference : other:'a t -> 'a t = "difference" [@@mel.send.pipe: 'a t]
Expand Down
11 changes: 5 additions & 6 deletions jscomp/runtime/js_weakmap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
type ('k, 'v) t

external make : unit -> ('k, 'v) t = "WeakMap" [@@mel.new]
external get : key:'k Js.dict -> 'v option = "get" [@@mel.send.pipe: ('k, 'v) t]
external has : key:'k Js.dict -> bool = "has" [@@mel.send.pipe: ('k, 'v) t]
external get : key:'k Js.dict -> ('k, 'v) t -> 'v option = "get" [@@mel.send]
external has : key:'k Js.dict -> ('k, 'v) t -> bool = "has" [@@mel.send]

external set : key:'k Js.dict -> value:'v -> ('k, 'v) t = "set"
[@@mel.send.pipe: ('k, 'v) t]
external set : key:'k Js.dict -> value:'v -> ('k, 'v) t -> ('k, 'v) t = "set"
[@@mel.send]

external delete : key:'k Js.dict -> bool = "delete"
[@@mel.send.pipe: ('k, 'v) t]
external delete : key:'k Js.dict -> ('k, 'v) t -> bool = "delete" [@@mel.send]
6 changes: 3 additions & 3 deletions jscomp/runtime/js_weakset.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
type 'a t

external make : unit -> 'a t = "WeakSet" [@@mel.new]
external add : value:'a Js.dict -> 'a t = "add" [@@mel.send.pipe: 'a t]
external delete : value:'a Js.dict -> bool = "delete" [@@mel.send.pipe: 'a t]
external has : value:'a Js.dict -> bool = "has" [@@mel.send.pipe: 'a t]
external add : value:'a Js.dict -> 'a t -> 'a t = "add" [@@mel.send]
external delete : value:'a Js.dict -> 'a t -> bool = "delete" [@@mel.send]
external has : value:'a Js.dict -> 'a t -> bool = "has" [@@mel.send]

0 comments on commit 174069f

Please sign in to comment.