Module Js

module Js : sig..end

Javascript binding

This module provides types and functions to interoperate with Javascript values, and gives access to Javascript standard objects.


Dealing with null and undefined values.

type +'a opt

Type of possibly null values.

type +'a optdef

Type of possibly undefined values.

val null : 'a opt

The null value.

val some : 'a -> 'a opt

Consider a value into a possibly null value.

val undefined : 'a optdef

The undefined value

val def : 'a -> 'a optdef

Consider a value into a possibly undefined value.

module type OPT = sig..end

Signatures of a set of standard functions for manipulating optional values.

module Opt : OPTwith type 'a t = 'a opt

Standard functions for manipulating possibly null values.

module Optdef : OPTwith type 'a t = 'a optdef

Standard functions for manipulating possibly undefined values.

Types for specifying method and properties of Javascript objects

type +'a t

Type of Javascript objects. The type parameter is used to specify more precisely an object.

type +'a meth

Type used to specify method types: a Javascript object <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 used to specify the properties of Javascript objects. In practice you should rarely need this type directly, but should rather use the type abbreviations below instead.

type 'a readonly_prop = < get : 'a > gen_prop

Type of read-only properties: a Javascript object <p : t Js.readonly_prop> Js.t has a read-only property p of type t.

type 'a writeonly_prop = < set : 'a -> unit > gen_prop

Type of write-only properties: a Javascript object <p : t Js.writeonly_prop> Js.t has a write-only property p of type t.

type 'a prop = < get : 'a; set : 'a -> unit > gen_prop

Type of read/write properties: a Javascript object <p : t Js.writeonly_prop> Js.t has a read/write property p of type t.

type 'a optdef_prop = < get : 'a optdef; set : 'a -> unit > gen_prop

Type of read/write properties that may be undefined: you can set them to a value of some type t, but if you read them, you will get a value of type t optdef (that may be undefined).

Object constructors

type +'a constr

A value of type (t1 -