package js_of_ocaml

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Js.UnsafeSource

Unsafe Javascript operations

Sourcetype top
Sourcetype any = top t

Top type. Used for putting values of different types in a same array.

Sourcetype any_js_array = any
Sourceval inject : 'a -> any

Coercion to top type.

Sourceval coerce : _ t -> _ t

Unsafe coercion between to Javascript objects.

Sourceval get : 'a -> 'b -> 'c

Get the value of an object property. The expression get o s returns the value of property s of object o.

Sourceval set : 'a -> 'b -> 'c -> unit

Set an object property. The expression set o s v set the property s of object o to value v.

Sourceval delete : 'a -> 'b -> unit

Delete an object property. The expression delete o s deletes property s of object o.

Sourceval call : 'a -> 'b -> any array -> 'c

Performs a Javascript function call. The expression call f o a calls the Javascript function f with the arguments given by the array a, and binding this to o.

Sourceval fun_call : 'a -> any array -> 'b

Performs a Javascript function call. The expression fun_call f a calls the Javascript function f with the arguments given by the array a.

Sourceval meth_call : 'a -> string -> any array -> 'b

Performs a Javascript method call. The expression meth_call o m a calls the Javascript method m of object o with the arguments given by the array a.

Sourceval new_obj : 'a -> any array -> 'b

Create a Javascript object. The expression new_obj c a creates a Javascript object with constructor c using the arguments given by the array a. Example: Js.new_obj (Js.Unsafe.variable "ArrayBuffer") [||]

Sourceval new_obj_arr : 'a -> any_js_array -> 'b

Same Create a Javascript object. The expression new_obj_arr c a creates a Javascript object with constructor c using the arguments given by the Javascript array a.

Sourceval obj : (string * any) array -> 'a

Creates a Javascript literal object. The expression obj a creates a Javascript object whose fields are given by the array a

Sourceval pure_expr : (unit -> 'a) -> 'a

Asserts that an expression is pure, and can therefore be optimized away by the compiler if unused.

Sourceval eval_string : string -> 'a

Evaluate Javascript code

Sourceval js_expr : string -> 'a

js_expr e will parse the JavaScript expression e if e is available at compile time or will fallback to a runtime evaluation. See eval_string

Sourceval pure_js_expr : string -> 'a

pure_js_expr str behaves like pure_expr (fun () -> js_expr str).

Sourceval global : < .. > t

Javascript global object

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

Wrap an OCaml function so that it can be invoked from Javascript. Contrary to Js.wrap_callback, partial application and over-application are not supported: missing arguments will be set to undefined and extra arguments are lost.

Sourceval callback_with_arguments : (any_js_array -> 'b) -> ('c, any_js_array -> 'b) 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 arguments JavaScript

Sourceval callback_with_arity : int -> ('a -> 'b) -> ('c, 'a -> 'b) meth_callback
Sourceval 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. Contrary to Js.wrap_meth_callback, partial application and over-application is not supported: missing arguments will be set to undefined and extra arguments are lost.

Sourceval meth_callback_with_arguments : ('b -> any_js_array -> 'a) -> ('b, any_js_array -> '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. The second parameter of the function with be bound to the value of the arguments.

Sourceval meth_callback_with_arity : int -> ('b -> 'a) -> ('b, 'a) meth_callback
Sourceval equals : _ -> _ -> bool

Javascript == equality operator.

Sourceval strict_equals : _ -> _ -> bool

Javascript === equality operator.

Deprecated functions.

Sourceval variable : string -> 'a

Access a Javascript variable. variable "foo" will return the current value of variable foo.

  • deprecated [since 2.6] use Js.Unsafe.pure_js_expr instead
OCaml

Innovation. Community. Security.