extenral match_ : string -> Js.Re.t -> (string array option [@bs.null])
That would indeed be quite nice, undefined would still be standalone though?
@OvermindDL1 I think we make it more general to justify its inclusion
external get : t -> int -> int = "" [@@bs.index]
[@@bs.return { throw_if_null = "error message $0 $1 $2" ;
throw_if_undefined = "xx" ;
(* option_if_null ; option_if_undefined ;
warn_if_null; warn_if_undefined
*) (* these flags are not compatible with [throw]*)
}]
The cool thing is that we can turn on [throw_if_null], [throw_if_undefined] for _FFIs in debug mode_, that will help find FFI bugs quickly.
Note we can make the post-assertion a little more general like
type_is_string ? type_is_int? type_is_number?
Or do it in a best effort style, by doing a console.warn
This would be also useful to check nan some JS API, returns either int or nan
For the return value we can also convert it from Js.boolean to bool. So that
user can just write Js.Float.isFinite
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@OvermindDL1 I think we make it more general to justify its inclusion
The cool thing is that we can turn on [throw_if_null], [throw_if_undefined] for _FFIs in debug mode_, that will help find FFI bugs quickly.