JvSourceJavaScript 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.
instanceof o c is true if o is an instance of constructor c.
is_null v is true iff v is strictly equal to null.
is_undefined v is true iff v is strictly equal to undefined.
of_option ~none conv o is none if o is None and conv v if o is Some v.
global refers to the global object.
The type for US-ASCII JavaScript object property names.
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.
to_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.
to_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.
of_int i is the int value i as a JavaScript Number value. The conversion is lossess.
to_float v is the JavaScript Number value v as a float value. The conversion is lossless.
of_float f is the float value f as a JavaScript Number value. The conversion is lossless.
to_int32 v is the JavaScript Number value v as an int32 value. The conversion is lossless provided v is a 32-bit signed integer.
of_int32 f is the int32 value f as a JavaScript Number value. The conversion is lossless.
of_string v is a JavaScript string from the UTF-8 encoded OCaml string v. Shortcut for of_jstr (Jstr.v v).
to_string v is an UTF-8 encoded OCaml string from the JavaScript string v. Shortcut for Jstr.to_string (to_jstr v).
is_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.
of_jv_array a is a as a JavaScript array of JavaScript values.
callback ~arity f makes function f with arity arity callable from JavaScript.
This 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.
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.
delete' o p deletes property p of o. The property p or o becomes undefined.
find_map' f p o is Option.map f (find' p o).
call' o m args calls method m on o with arguments m. m must be a JavaScript string.
debugger () stops and enters the JavaScript debugger (if available).
has p v tests whether Jv.repr v has a member or method p
defined v is Jv.is_some (J.repr v). Tests whether v is neither null nor undefined.