module Js:Javascript bindingsig..end
This module provides types and functions to interoperate with
Javascript values, and gives access to Javascript standard
objects.
null and undefined values.type +'a opt
type +'a optdef
val null : 'a optnull value.val some : 'a -> 'a optval undefined : 'a optdefundefined valueval def : 'a -> 'a optdefmodule type OPT =sig..end
module Opt:OPTwith type 'a t = 'a opt
module Optdef:OPTwith type 'a t = 'a optdef
type +'a t
type +'a meth
<m : t1 -> t2 -> ... -> tn -> t Js.meth> Js.t
has a Javascript method m expecting n arguments
of types t1 to tn and returns a value of type t.type +'a gen_prop
type'areadonly_prop =< get : 'a > gen_prop
<p : t Js.readonly_prop> Js.t
has a read-only property p of type t.type'awriteonly_prop =< set : 'a -> unit > gen_prop
<p : t Js.writeonly_prop> Js.t
has a write-only property p of type t.type'aprop =< get : 'a; set : 'a -> unit > gen_prop
<p : t Js.writeonly_prop> Js.t
has a read/write property p of type t.type'aoptdef_prop =< get : 'a optdef; set : 'a -> unit > gen_prop
t, but if you read
them, you will get a value of type t optdef (that may be
undefined).typefloat_prop =< get : float t; set : float -> unit > gen_prop
float, but you will get back a
native Javascript number of type float t.type +'a constr
(t1 -> ... -> tn -> t Js.t) Js.constr is a
Javascript constructor expecting n arguments of types t1
to tn and returning a Javascript object of type t Js.t. Use
the syntax extension jsnew c (e1, ..., en) to build an object
using constructor c and arguments e1 to en.type (-'a, +'b) meth_callback
(u, t1 -> ... -> tn -> t) meth_callback can be called
from Javascript with this bound to a value of type u
and up to n arguments of types t1 to tn. The system
takes care of currification, so less than n arguments can
be provided. As a special case, a callback of type
(t, unit -> t) meth_callback can be called from Javascript
with no argument. It will behave as if it was called with a
single argument of type unit.type'acallback =(unit, 'a) meth_callback
this implicit parameter.val wrap_callback : ('a -> 'b) -> ('c, 'a -> 'b) meth_callbackval wrap_meth_callback : ('a -> 'b -> 'c) -> ('a, 'b -> 'c) meth_callbackthis implicit parameter.val _true : bool ttrue boolean.val _false : bool tfalse boolean.type match_result_handle
Js.match_result
to get the corresponding MatchResult object.
(This type is used to resolved the mutual dependency between
string and array type definitions.)type string_array
Array
object using function Js.str_array.
(This type is used to resolved the mutual dependency between
string and array type definitions.)class type js_string =object..end
class type regExp =object..end
val regExp : (js_string t -> regExp t) constrRegExp objects. The expression jsnew regExp (s)
builds the regular expression specified by string s.val regExp_withFlags : (js_string t -> js_string t -> regExp t) constrRegExp objects. The expression
jsnew regExp (s, f) builds the regular expression specified by
string s using flags f.val regExp_copy : (regExp t -> regExp t) constrRegExp objects. The expression
jsnew regExp (r) builds a copy of regular expression r.class type['a]js_array =object..end
val array_empty : 'a js_array t constrArray objects. The expression
jsnew array_empty () returns an empty array.val array_length : (int -> 'a js_array t) constrArray objects. The expression
jsnew array_empty (l) returns an array of length l.val array_get : 'a #js_array t -> int -> 'a optdefarray_get a i returns the element at index i
of array a. Returns undefined if there is no element at
this index.val array_set : 'a #js_array t -> int -> 'a -> unitarray_set a i v puts v at index i in
array a.class type match_result =object..end
val str_array : string_array t -> js_string t js_array tstring_array t object into an array of
string. (Used to resolved the mutual dependency between string
and array type definitions.)val match_result : match_result_handle t -> match_result tMatchResult object.
(Used to resolved the mutual dependency between string
and array type definitions.)class type number =object..end
val number_of_float : float -> number tval float_of_number : number t -> floatclass type date =object..end
val date_now : date t constrDate objects: new date_now () returns a
Date object initialized with the current date.val date_fromTimeValue : (float -> date t) constrDate objects: new date_fromTimeValue (t) returns a
Date object initialized with the time value t.val date_month : (int -> int -> date t) constrDate objects: new date_fromTimeValue (y, m)
returns a Date object corresponding to year y and month m.val date_day : (int -> int -> int -> date t) constrDate objects: new date_fromTimeValue (y, m, d)
returns a Date object corresponding to year y, month m and
day d.val date_hour : (int -> int -> int -> int -> date t) constrDate objects: new date_fromTimeValue (y, m, d, h)
returns a Date object corresponding to year y to hour h.val date_min : (int -> int -> int -> int -> int -> date t) constrDate objects: new date_fromTimeValue (y, m, d, h, m')
returns a Date object corresponding to year y to minute m'.val date_sec : (int -> int -> int -> int -> int -> int -> date t) constrDate objects:
new date_fromTimeValue (y, m, d, h, m', s)
returns a Date object corresponding to year y to second s.val date_ms : (int -> int -> int -> int -> int -> int -> int -> date t) constrDate objects:
new date_fromTimeValue (y, m, d, h, m', s, ms)
returns a Date object corresponding to year y
to millisecond ms.class type date_constr =object..end
val date : date_constr tclass type math =object..end
val math : math tval decodeURI : js_string t -> js_string tval decodeURIComponent : js_string t -> js_string tval encodeURI : js_string t -> js_string tval encodeURIComponent : js_string t -> js_string tencodeURI, but also encode URI reserved characters.val escape : js_string t -> js_string tval unescape : js_string t -> js_string tval bool : bool -> bool tval to_bool : bool t -> boolval string : string -> js_string tval to_string : js_string t -> stringval float : float -> float tval to_float : float t -> floatval array : 'a array -> 'a js_array tval to_array : 'a js_array t -> 'a arrayval bytestring : string -> js_string tval to_bytestring : js_string t -> stringval coerce : 'a -> ('a -> 'b Opt.t) -> ('a -> 'b) -> 'bcoerce v c f attempts to apply coercion c to value v.
If the coercion returns null, function f is called.val coerce_opt : 'a Opt.t -> ('a -> 'b Opt.t) -> ('a -> 'b) -> 'bcoerce_opt v c f attempts to apply coercion c to value v.
If v is null or the coercion returns null, function f is
called.
Typical usage is the following:
Js.coerce_opt (Dom_html.getElementById id)
Dom_html.CoerceTo.div (fun _ -> assert false)val typeof : < .. > t -> js_string tval instanceof : < .. > t -> 'a constr -> boolmodule Unsafe:sig..end