Base.Value
Generate javascript values from ocaml values.
val null : t
The javascript value null
.
val undefined : t
The javascript value undefined
.
val int : int -> t
int i
The integer i
as a javascript value.
This function is the identity function, because int
is represented in javascript as a number which is a 64 bit floating point value.
As long as we stay within ocaml code, 32 bit signed integer arithmetics is done.
val float : float -> t
float v
The floating point value v
as a javascript value.
This function is the identity function, because float
is represented in javascript as a number which is a 64 bit floating point value.
val bool : bool -> t
bool b
Convert the ocaml boolean value b
into a javascript boolean value.
val string : string -> t
string s
Convert the ocaml string s
into a javascript string.
In ocaml a string is a sequence of bytes and in javascript a string is a sequence of utf16 code points.
_object [|name1, value1; name2, value2; ...|]
Make the javascript object {name1: value1, name2: value2, ...}
.
array arr
Convert the ocaml array arr
of javascript objects into the corresponding javascript array.
function1 f
Convert the ocaml function f
of type t -> t
into the corresponding javascript function.
No actual conversion is necessary, because ocaml functions are compiled to javascript functions.
However javascript cannot do currying i.e. partial application. In javascript the corresponding function can be called with zero or more arguments.
If there are arguments missing, then the function will be called with sufficient arguments filled up by undefined
.
If more arguments are supplied, then the superfluous arguments are ignored.
function2 f
See function1
, just that here f
is a two argument function.
function3 f
See function1
, just that here f
is a three argument function.
stringify v
convert the javascript value v
to a json string. This possible only if the javascript value is one of: