JvJavaScript values.
The type for JavaScript values. A value of this type represents a value of any JavaScript primitive type.
equal v0 v1 is JavaScript == equality.
strict_equal v0 v1 is JavaScript's strict equality. OCaml's (==) is mapped on that equality.
val repr : 'a -> trepr v is the OCaml value v as its JavaScript value representation.
val is_null : t -> boolis_null v is true iff v is strictly equal to null.
val is_undefined : t -> boolis_undefined v is true iff v is strictly equal to undefined.
val is_none : t -> boolis_none v is is_null v || is_undefined v.
val is_some : t -> boolis_some v is not (is_none v).
of_option ~none conv o is none if o is None and conv v if o is Some v.
val global : tglobal refers to the global object.
delete o p deletes property p of o. The property p or o becomes undefined.
set_if_some o p v sets property p of o if v is Some p. Otherwise the p is left untouched in o.
call o m args calls the method named m on o with arguments m. m is assumed to be made of US-ASCII characters only, use call' if that is not the case.
val true' : ttrue is JavaScript true.
val false' : tfalse' is JavaScript false.
val to_bool : t -> boolto_bool v is the JavaScript Boolean value v as a bool value. This is unsafe, only use if v is guaranted to be a JavaScript boolean.
val of_bool : bool -> tof_bool b is the bool value b as a JavaScript Boolean value.
module Bool : sig ... endbool properties accessors.
val to_int : t -> intto_int v is the JavaScript Number value v as an int value. The conversion is lossless provided v is integral. This is unsafe, only use if v is guaranteed to be a JavaScript number.
val of_int : int -> tof_int i is the int value i as a JavaScript Number value. The conversion is lossess.
module Int : sig ... endint properties accessors.
val to_float : t -> floatto_float v is the JavaScript Number value v as a float value. The conversion is lossless.
val of_float : float -> tof_float f is the float value f as a JavaScript Number value. The conversion is lossless.
module Float : sig ... endfloat object properties.
val to_int32 : t -> int32to_int32 v is the JavaScript Number value v as an int32 value. The conversion is lossless provided v is a 32-bit signed integer.
val of_int32 : int32 -> tof_int32 f is the int32 value f as a JavaScript Number value. The conversion is lossless.
module Int32 : sig ... endint32 object properties.
module Jstr : sig ... endJstr object properties.
val of_string : string -> tof_string v is a JavaScript string from the UTF-8 encoded OCaml string v. Shortcut for of_jstr (Jstr.v v).
val to_string : t -> stringto_string v is an UTF-8 encoded OCaml string from the JavaScript string v. Shortcut for Jstr.to_string (to_jstr v).
val is_array : jv -> boolis_array v determines if v is a JavaScript array using the Array.isArray function.
to_array conv a is an array value made of the JavaScript array a whose elements are converted with conv.
of_array conv a is a JavaScript Array value made of the array value a whose element are converted to JavaScript values with conv.
to_list conv a is a list value made of the JavaScript array a whose elements are converted with conv.
of_list conv l is the JavaScript Array value made of the list value l whose element are converted to JavaScript values with conv.
Can be faster.
module Jarray : sig ... endJavaScript arrays.
val callback : arity:int -> (_ -> _) -> tcallback ~arity f makes function f with arity arity callable from JavaScript.
module Error : sig ... endError objects.
exception Error of Error.tThis OCaml exception represents any exception thrown by JavaScript code that is an instance of the Error exception. You should match on this exception in OCaml code to catch JavaScript exceptions.
throw ?name msg throws a JavaScript exception with error object Jv.Error.v ?name msg.
module It : sig ... endJavaScript iterator protocol.
module Promise : sig ... endJavaScript promise support.
The functions above only work with US-ASCII OCaml string literals. If you hit general Unicode identifiers create JavaScript strings representing them with Jstr.v and use the following functions.
type prop' = Jstr.tThe type for full Unicode JavaScript object property names.
delete' o p deletes property p of o. The property p or o becomes undefined.
call' o m args calls method m on o with arguments m. m must be a JavaScript string.
defined v is Jv.is_some (J.repr v). Tests whether v is neither null nor undefined.
module type CONV = sig ... endAbstract type conversion iterface.