Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime(Js.{FormData,Blob,File}): port @mel.send externals to use @mel.send #1304

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jscomp/runtime/js_blob.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ external bytes : t -> Js.uint8Array Js.promise = "bytes"
(** [bytes t] returns a Promise that resolves with a [Js.uint8Array] containing
the contents of the blob as an array of bytes. *)

external slice : ?start:int -> ?end_:int -> ?contentType:string -> t -> t
external slice :
?start:int -> ?end_:int -> ?contentType:string -> (t[@mel.this]) -> t
= "slice"
[@@mel.send]
(** [slice ?start ?end_ ?contentType t] creates and returns a new Blob object
Expand Down
3 changes: 2 additions & 1 deletion jscomp/runtime/js_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ external bytes : t -> Js.uint8Array Js.promise = "bytes"
(** [bytes t] returns a Promise that resolves with a [Js.uint8Array] containing
the contents of the file as an array of bytes. *)

external slice : ?start:int -> ?end_:int -> ?contentType:string -> t -> t
external slice :
?start:int -> ?end_:int -> ?contentType:string -> (t[@mel.this]) -> t
= "slice"
[@@mel.send]
(** [slice ?start ?end_ ?contentType t] creates and returns a new File object
Expand Down
16 changes: 8 additions & 8 deletions jscomp/runtime/js_formData.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ external append :
value:
([ `String of string | `Object of < .. > Js.t | `Dict of _ Js.dict ]
[@mel.unwrap]) ->
t ->
(t[@mel.this]) ->
unit = "append"
[@@mel.send]
(** [append t ~name ~value] appends a new value onto an existing key inside a
Expand All @@ -53,25 +53,25 @@ external appendBlob :
name:string ->
value:([ `Blob of Js.blob | `File of Js.file ][@mel.unwrap]) ->
?filename:string ->
t ->
(t[@mel.this]) ->
unit = "append"
[@@mel.send]
(** [appendBlob t ~name ~value] appends a new value onto an existing key inside
a FormData object, or adds the key if it does not already exist. This
method differs from [append] in that instances in the Blob hierarchy can
pass a third filename argument. *)

external delete : name:string -> t -> unit = "delete"
external delete : name:string -> (t[@mel.this]) -> unit = "delete"
[@@mel.send]
(** [delete t ~name] deletes a key and its value(s) from a FormData object. *)

external get : name:string -> t -> entryValue option = "get"
external get : name:string -> (t[@mel.this]) -> entryValue option = "get"
[@@mel.send] [@@mel.return null_to_opt]
(** [get t ~name] returns the first value associated with a given key from
within a FormData object. If you expect multiple values and want all of
them, use {!getAll} instead. *)

external getAll : name:string -> t -> entryValue array = "getAll"
external getAll : name:string -> (t[@mel.this]) -> entryValue array = "getAll"
[@@mel.send]
(** [getAll t ~name] returns all the values associated with a given key from
within a FormData object. *)
Expand All @@ -80,7 +80,7 @@ external set :
name:string ->
([ `String of string | `Object of < .. > Js.t | `Dict of _ Js.dict ]
[@mel.unwrap]) ->
t ->
(t[@mel.this]) ->
unit = "set"
[@@mel.send]
(** [set t ~name ~value] sets a new value for an existing key inside a FormData
Expand All @@ -90,15 +90,15 @@ external setBlob :
name:string ->
([ `Blob of Js.blob | `File of Js.file ][@mel.unwrap]) ->
?filename:string ->
t ->
(t[@mel.this]) ->
unit = "set"
[@@mel.send]
(** [setBlob t ~name ~value ?filename] sets a new value for an existing key
inside a FormData object, or adds the key/value if it does not already
exist. This method differs from [set] in that instances in the Blob
hierarchy can pass a third filename argument. *)

external has : name:string -> t -> bool = "has"
external has : name:string -> (t[@mel.this]) -> bool = "has"
[@@mel.send]
(** [has ~name t] returns whether a FormData object contains a certain key. *)

Expand Down
Loading