Module Js.Unsafe
Unsafe Javascript operations
type toptype any_js_array = anyval inject : 'a -> anyCoercion to top type.
val get : 'a -> 'b -> 'cGet the value of an object property. The expression get o s returns the value of property s of object o.
val set : 'a -> 'b -> 'c -> unitSet an object property. The expression set o s v set the property s of object o to value v.
val delete : 'a -> 'b -> unitDelete an object property. The expression delete o s deletes property s of object o.
val call : 'a -> 'b -> any array -> 'cPerforms 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.
val fun_call : 'a -> any array -> 'bPerforms a Javascript function call. The expression fun_call f a calls the Javascript function f with the arguments given by the array a.
val meth_call : 'a -> string -> any array -> 'bPerforms 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.
val new_obj : 'a -> any array -> 'bCreate 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") [||]
val new_obj_arr : 'a -> any_js_array -> 'bSame 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.
val obj : (string * any) array -> 'aCreates a Javascript literal object. The expression obj a creates a Javascript object whose fields are given by the array a
val pure_expr : (unit -> 'a) -> 'aAsserts that an expression is pure, and can therefore be optimized away by the compiler if unused.
val eval_string : string -> 'aEvaluate Javascript code
val js_expr : string -> 'ajs_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
val pure_js_expr : string -> 'apure_js_expr str behaves like pure_expr (fun () -> js_expr str).
val runtime_value : string -> 'aruntime_value "FOO" returns the JavaScript value FOO provided by the JavaScript runtime (with '//Provides: FOO'). The string argument must be a string literal.
val global : < .. > tJavascript global object
val callback : ('a -> 'b) -> ('c, 'a -> 'b) meth_callbackWrap 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.
val callback_with_arguments :
(any_js_array -> 'b) ->
('c, any_js_array -> 'b) meth_callbackWrap an OCaml function so that it can be invoked from Javascript. The first parameter of the function will be bound to the arguments JavaScript
val callback_with_arity : int -> ('a -> 'b) -> ('c, 'a -> 'b) meth_callbackval meth_callback : ('b -> 'a) -> ('b, 'a) meth_callbackWrap 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.
val meth_callback_with_arguments :
('b -> any_js_array -> 'a) ->
('b, any_js_array -> 'a) meth_callbackWrap 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.
val meth_callback_with_arity : int -> ('b -> 'a) -> ('b, 'a) meth_callbackval equals : _ -> _ -> boolJavascript == equality operator.
val strict_equals : _ -> _ -> boolJavascript === equality operator.
Deprecated functions.
val variable : string -> 'aAccess a Javascript variable. variable "foo" will return the current value of variable foo.