package vue-jsoo

  1. Overview
  2. Docs

Module MjsSource

include module type of struct include Ezjs_min end
Sourcemodule Ezjs_dom = Ezjs_min.Ezjs_dom
Sourcemodule Log = Ezjs_min.Log
Sourcemodule Promise = Ezjs_min.Promise
include module type of struct include Js_of_ocaml.Js end

Dealing with null and undefined values.

Sourcetype +'a opt = 'a Js_of_ocaml.Js.opt

Type of possibly null values.

Sourcetype +'a optdef = 'a Js_of_ocaml.Js.optdef

Type of possibly undefined values.

Sourceval null : 'a opt

The null value.

Sourceval some : 'a -> 'a opt

Consider a value into a possibly null value.

Sourceval undefined : 'a optdef

The undefined value

Sourceval def : 'a -> 'a optdef

Consider a value into a possibly undefined value.

Sourcemodule type OPT = Ezjs_min.OPT

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

Sourcemodule Opt = Ezjs_min.Opt

Standard functions for manipulating possibly null values.

Sourcemodule Optdef = Ezjs_min.Optdef

Standard functions for manipulating possibly undefined values.

Types for specifying method and properties of Javascript objects

Sourcetype +'a t = 'a Js_of_ocaml.Js.t

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

Sourcetype +'a meth = 'a Js_of_ocaml.Js.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.

Sourcetype +'a gen_prop = 'a Js_of_ocaml.Js.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.

Sourcetype '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.

Sourcetype '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.

Sourcetype '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.

Sourcetype '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

Sourcetype +'a constr = 'a Js_of_ocaml.Js.constr

A value of type (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 new%js c e1 ... en to build an object using constructor c and arguments e1 to en.

Callbacks to OCaml

Sourcetype (-'a, +'b) meth_callback = ('a, 'b) Js_of_ocaml.Js.meth_callback

Type of callback functions. A function of type (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.

Sourcetype 'a callback = (unit, 'a) meth_callback

Type of callback functions intended to be called without a meaningful this implicit parameter.

Sourceval wrap_callback : ('a -> 'b) -> ('c, 'a -> 'b) meth_callback

Wrap an OCaml function so that it can be invoked from Javascript.

Sourceval wrap_meth_callback : ('b -> 'a) -> ('b, 'a) meth_callback

Wrap an OCaml function so that it can be invoked from Javascript. The first parameter of the function will be bound to the value of the this implicit parameter.

Javascript comparisons

Sourceval equals : _ t -> _ t -> bool

Javascript == equality operator.

Sourceval strict_equals : _ t -> _ t -> bool

Javascript === equality operator.

Javascript standard objects

Sourceval _true : bool t

Javascript true boolean.

Sourceval _false : bool t

Javascript false boolean.

Sourcetype match_result_handle = Js_of_ocaml.Js.match_result_handle

A handle to a match result. Use function Js.match_result to get the corresponding MatchResult object. (This type is used to resolved the mutual dependency between string and array type definitions.)

Opaque type for string arrays. You can get the actual Array object using function Js.str_array. (This type is used to resolved the mutual dependency between string and array type definitions.)

Opaque type for Unicode normalization forms.

Canonical Decomposition

Canonical Decomposition, followed by Canonical Composition

Compatibility Decomposition

Compatibility Decomposition, followed by Canonical Composition

Specification of Javascript number objects.

Sourceclass type number = object ... end
Sourceclass type js_string = object ... end

Specification of Javascript string objects.

Sourceclass type regExp = object ... end

Specification of Javascript regular expression objects.

Sourcetype number_t = number t
Sourceclass type string_constr = object ... end

Specification of the string constructor, considered as an object.

Sourceval string_constr : string_constr t

The string constructor, as an object.

Sourceval regExp : (js_string t -> regExp t) constr

Constructor of RegExp objects. The expression new%js regExp s builds the regular expression specified by string s.

Sourceval regExp_withFlags : (js_string t -> js_string t -> regExp t) constr

Constructor of RegExp objects. The expression new%js regExp s f builds the regular expression specified by string s using flags f.

Sourceval regExp_copy : (regExp t -> regExp t) constr

Constructor of RegExp objects. The expression new%js regExp r builds a copy of regular expression r.

Sourceclass type 'a js_array = object ... end

Specification of Javascript regular arrays. Use Js.array_get and Js.array_set to access and set array elements.

Sourceval object_keys : 'a t -> js_string t js_array t

Returns jsarray containing keys of the object as Object.keys does.

Sourceval array_empty : 'a js_array t constr

Constructor of Array objects. The expression new%js array_empty returns an empty array.

Sourceval array_length : (int -> 'a js_array t) constr

Constructor of Array objects. The expression new%js array_length l returns an array of length l.

Sourceval array_get : 'a js_array t -> int -> 'a optdef

Array access: array_get a i returns the element at index i of array a. Returns undefined if there is no element at this index.

Sourceval array_set : 'a js_array t -> int -> 'a -> unit

Array update: array_set a i v puts v at index i in array a.

Sourceval array_map : ('a -> 'b) -> 'a js_array t -> 'b js_array t

Array map: array_map f a is a##map(wrap_callback (fun elt idx arr -> f elt)).

Sourceval array_mapi : (int -> 'a -> 'b) -> 'a js_array t -> 'b js_array t

Array mapi: array_mapi f a is a##map(wrap_callback (fun elt idx arr -> f idx elt)).

Sourceclass type match_result = object ... end

Specification of match result objects

Convert an opaque string_array t object into an array of string. (Used to resolved the mutual dependency between string and array type definitions.)

Convert a match result handle into a MatchResult object. (Used to resolved the mutual dependency between string and array type definitions.)

Sourceclass type date = object ... end

Specification of Javascript date objects.

Sourceval date_now : date t constr

Constructor of Date objects: new%js date_now returns a Date object initialized with the current date.

Sourceval date_fromTimeValue : (number_t -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue t returns a Date object initialized with the time value t.

Sourceval date_month : (int -> int -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue y m returns a Date object corresponding to year y and month m.

Sourceval date_day : (int -> int -> int -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue y m d returns a Date object corresponding to year y, month m and day d.

Sourceval date_hour : (int -> int -> int -> int -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue y m d h returns a Date object corresponding to year y to hour h.

Sourceval date_min : (int -> int -> int -> int -> int -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue y m d h m' returns a Date object corresponding to year y to minute m'.

Sourceval date_sec : (int -> int -> int -> int -> int -> int -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue y m d h m' s returns a Date object corresponding to year y to second s.

Sourceval date_ms : (int -> int -> int -> int -> int -> int -> int -> date t) constr

Constructor of Date objects: new%js date_fromTimeValue y m d h m' s ms returns a Date object corresponding to year y to millisecond ms.

Sourceclass type date_constr = object ... end

Specification of the date constructor, considered as an object.

Sourceval date : date_constr t

The date constructor, as an object.

Sourceclass type math = object ... end

Specification of Javascript math object.

Sourceval math : math t

The Math object

Sourceclass type error = object ... end

Specification of Javascript error object.

Sourceval error_constr : (js_string t -> error t) constr

Constructor of Error objects: new%js error_constr msg returns an Error object with the message msg.

Sourcemodule Js_error = Ezjs_min.Js_error
Sourceclass type json = object ... end

Specification of Javascript JSON object.

Sourceval _JSON : json t

JSON object

Standard Javascript functions

Sourceval decodeURI : js_string t -> js_string t

Decode a URI: replace by the corresponding byte all escape sequences but the ones corresponding to a URI reserved character and convert the string from UTF-8 to UTF-16.

Sourceval decodeURIComponent : js_string t -> js_string t

Decode a URIComponent: replace all escape sequences by the corresponding byte and convert the string from UTF-8 to UTF-16.

Sourceval encodeURI : js_string t -> js_string t

Encode a URI: convert the string to UTF-8 and replace all unsafe bytes by the corresponding escape sequence.

Sourceval encodeURIComponent : js_string t -> js_string t

Same as encodeURI, but also encode URI reserved characters.

Sourceval escape : js_string t -> js_string t

Escape a string: unsafe UTF-16 code points are replaced by 2-digit and 4-digit escape sequences.

Sourceval unescape : js_string t -> js_string t

Unescape a string: 2-digit and 4-digit escape sequences are replaced by the corresponding UTF-16 code point.

Sourceval isNaN : 'a -> bool
Sourceval parseInt : js_string t -> int
Sourceval parseFloat : js_string t -> number_t

Conversion functions between Javascript and OCaml types

Sourceval bool : bool -> bool t

Conversion of booleans from OCaml to Javascript.

Sourceval to_bool : bool t -> bool

Conversion of booleans from Javascript to OCaml.

Sourceval string : string -> js_string t

Conversion of strings from OCaml to Javascript. (The OCaml string is considered to be encoded in UTF-8 and is converted to UTF-16.)

Sourceval to_string : js_string t -> string

Conversion of strings from Javascript to OCaml.

Sourceval array : 'a array -> 'a js_array t

Conversion of arrays from OCaml to Javascript.

Sourceval to_array : 'a js_array t -> 'a array

Conversion of arrays from Javascript to OCaml.

Sourceval bytestring : string -> js_string t

Conversion of strings of bytes from OCaml to Javascript. (Each byte will be converted in an UTF-16 code point.)

Sourceval to_bytestring : js_string t -> string

Conversion of strings of bytes from Javascript to OCaml. (The Javascript string should only contain UTF-16 code points below 255.)

Sourceval float : float -> number_t

Conversion of OCaml floats to Javascript numbers.

Sourceval to_float : number_t -> float

Conversion of Javascript numbers to OCaml floats.

Sourceval number_of_float : float -> number t

Conversion of OCaml floats to Javascript number objects.

Sourceval float_of_number : number t -> float

Conversion of Javascript number objects to OCaml floats.

Sourceval int32 : int32 -> number_t

Conversion of OCaml floats to Javascript numbers.

Sourceval to_int32 : number_t -> int32

Conversion of Javascript numbers to OCaml 32-bits. The given floating-point number is truncated to an integer.

Sourceval nativeint : nativeint -> number_t

Conversion of OCaml 32-bits integers to Javascript numbers.

Sourceval to_nativeint : number_t -> nativeint

Conversion of Javascript numbers to OCaml native integers. The given floating-point number is truncated to an integer.

Convenience coercion functions

Sourceval coerce_opt : 'a Opt.t -> ('a -> 'b Opt.t) -> ('a -> 'b) -> 'b

Apply a possibly failing coercion function. coerce_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.document##getElementById id)
Dom_html.CoerceTo.div (fun _ -> assert false)

Type checking operators.

Sourceval typeof : _ t -> js_string t

Returns the type of a Javascript object.

Sourceval instanceof : _ t -> _ constr -> bool

Tests whether a Javascript object is an instance of a given class.

Debugging operations.

Sourceval debugger : unit -> unit

Invokes any available debugging functionality. If no debugging functionality is available, it has no effect. In practice, it will insert a "debugger;" statement in the generated javascript.

Export functionality.

Export values to module.exports if it exists or to the global object otherwise.

Sourceval export : string -> 'a -> unit

export name value export name

Sourceval export_all : 'a t -> unit

export_all obj export every key of obj object.

export_all
  object%js
    method add x y = x +. y
    method abs x = abs_float x
    val zero = 0.
  end

Unsafe operations.

Sourcemodule Unsafe = Ezjs_min.Unsafe

Unsafe Javascript operations

Deprecated functions and types.

Sourceval string_of_error : error t -> string
  • deprecated [since 4.0] Use [Js_error.to_string] instead.
Sourceval raise_js_error : error t -> 'a
  • deprecated [since 4.0] Use [Js_error.raise_] instead.
Sourceval exn_with_js_backtrace : exn -> force:bool -> exn

Attach a JavasScript error to an OCaml exception. if force = false and a JavasScript error is already attached, it will do nothing. This function is useful to store and retrieve information about JavaScript stack traces.

Attaching JavasScript errors will happen automatically when compiling with --enable with-js-error.

  • deprecated [since 4.0] Use [Js_error.raise_] instead.
Sourceval js_error_of_exn : exn -> error t opt

Extract a JavaScript error attached to an OCaml exception, if any. This is useful to inspect an eventual stack strace, especially when sourcemap is enabled.

  • deprecated [since 4.0] Use [Js_error.of_exn] instead.
Sourceexception Error of error t

The Error exception wrap javascript exceptions when caught by OCaml code. In case the javascript exception is not an instance of javascript Error, it will be serialized and wrapped into a Failure exception.

  • deprecated [since 4.0] Use [Js_error.Exn] instead.
Sourcetype float_prop = number_t prop
  • deprecated [since 2.0].

Type of float properties.

Sourcemodule Url = Ezjs_min.Url
Sourcemodule Dom_html = Ezjs_min.Dom_html
Sourcemodule Firebug = Ezjs_min.Firebug
Sourcemodule File = Ezjs_min.File
Sourcemodule Dom = Ezjs_min.Dom
Sourcemodule Typed_array = Ezjs_min.Typed_array
Sourcemodule Regexp = Ezjs_min.Regexp
Sourcetype ('a, 'b) result = ('a, 'b) result =
  1. | Ok of 'a
  2. | Error of 'b
Sourcetype window = Dom_html.window
Sourceval to_arrayf : ('a -> 'b) -> 'a js_array t -> 'b array
Sourceval of_arrayf : ('a -> 'b) -> 'a array -> 'b js_array t
Sourceval to_list : 'a js_array t -> 'a list
Sourceval of_list : 'a list -> 'a js_array t
Sourceval to_listf : ('a -> 'b) -> 'a js_array t -> 'b list
Sourceval of_listf : ('a -> 'b) -> 'a list -> 'b js_array t
Sourceval optdef : ('a -> 'b) -> 'a option -> 'b optdef
Sourceval to_optdef : ('a -> 'b) -> 'a Optdef.t -> 'b option
Sourceval unoptdef_f : 'a -> ('b -> 'a) -> 'b Optdef.t -> 'a
Sourceval unoptdef : 'a -> 'a Optdef.t -> 'a
Sourceval convdef : ('a -> 'b) -> 'a Optdef.t -> 'b optdef
Sourceval to_opt : ('a -> 'b) -> 'a Opt.t -> 'b option
Sourceval opt : ('a -> 'b) -> 'a option -> 'b opt
Sourceval convopt : ('a -> 'b) -> 'a Opt.t -> 'b opt
Sourceval js_log : 't0 -> unit
Sourceval log_str : string -> unit
Sourceval log : ('a, Format.formatter, unit, unit) format4 -> 'a
Sourceval error_of_string : string -> error Js_of_ocaml.Js.t
Sourceval catch_exn : (Js_error.error_t -> 'a) -> exn -> 'a
Sourcemodule AOpt = Ezjs_min.AOpt
Sourcetype 'a aopt = 'a AOpt.t
Sourcetype 'a case_prop = < get : 'a optdef > gen_prop
Sourceval choose_case_opt : 'a Optdef.t list -> 'a optdef
Sourceval choose_case : 'a list -> 'a optdef
Sourceval object_cs : 'res
Sourceval assign : 'a t -> 'b t -> 'c Js_of_ocaml__Js.t
Sourceval assign_list : Unsafe.any list -> 'a Js_of_ocaml__Js.t
Sourceval remove_undefined : 'a t -> unit
Sourcemodule Table = Ezjs_min.Table
Sourcemodule BigInt = Ezjs_min.BigInt
Sourcetype top = Unsafe.top
Sourcetype any = Unsafe.any
Sourceval def_list : ('a list -> 'b) -> 'a list -> 'b optdef
Sourceval manip_list : ('a list -> 'b list) -> 'a js_array t -> 'b js_array t
Sourcetype 'a table = 'a Table.t
Sourcetype 'a table_cons =
  1. | T of 'a table
  2. | L of (string * 'a) list
Sourceval to_table : 'a table_cons -> 'a table
Sourceval to_tablef : ('a -> 'b) -> 'a table_cons -> 'a table
Sourceval to_table_def : 'a table_cons -> 'a table optdef
Sourceval to_tablef_def : ('a -> 'b) -> 'a table_cons -> 'a table optdef
Sourceval to_any : 'a -> Unsafe.any
Sourceval coerce : 'a Js_of_ocaml__Js.t -> 'b Js_of_ocaml__Js.t
Sourceval to_any_table : ('a -> 'b) -> 'a table_cons -> 'b table_cons
Sourceclass type unit_promise = [unit, error t] Promise.promise0
OCaml

Innovation. Community. Security.