Module Js

This library provides bindings and necessary support for JS FFI. It contains all bindings into Js namespace.

[| 1;2;3;4|]
|. Js.Array2.map (fun x -> x + 1 )
|. Js.Array2.reduce (+) 0
|. Js.log
module Fn : sig ... end
val toOption : 'a Js__.Js_internal.nullable -> 'a option
val undefinedToOption : 'a Js__.Js_internal.undefined -> 'a option
val nullToOption : 'a Js__.Js_internal.null -> 'a option
val isNullable : 'a Js__.Js_internal.nullable -> bool
val testAny : 'a -> bool

The same as test except that it is more permissive on the types of input

val null : 'a Js__.Js_internal.null

The same as empty in Js.Null will be compiled as null

val undefined : 'a Js__.Js_internal.undefined

The same as empty Js.Undefined will be compiled as undefined

val typeof : 'a -> string

typeof x will be compiled as typeof x in JS Please consider functions in Types for a type safe way of reflection

val log : 'a -> unit

A convenience function to log everything

val log2 : 'a -> 'b -> unit
val log3 : 'a -> 'b -> 'c -> unit
val log4 : 'a -> 'b -> 'c -> 'd -> unit
val logMany : 'a array -> unit

A convenience function to log more than 4 arguments

val eqNull : 'a -> 'a Js__.Js_internal.null -> bool
val eqUndefined : 'a -> 'a Js__.Js_internal.undefined -> bool
val eqNullable : 'a -> 'a Js__.Js_internal.nullable -> bool
operators
val unsafe_lt : 'a -> 'a -> bool

unsafe_lt a b will be compiled as a < b. It is marked as unsafe, since it is impossible to give a proper semantics for comparision which applies to any type

val unsafe_le : 'a -> 'a -> bool

unsafe_le a b will be compiled as a <= b. See also unsafe_lt

val unsafe_gt : 'a -> 'a -> bool

unsafe_gt a b will be compiled as a > b. See also unsafe_lt

val unsafe_ge : 'a -> 'a -> bool

unsafe_ge a b will be compiled as a >= b. See also unsafe_lt

Types for JS objects

type 'a t

This used to be mark a Js object type.

type +'a null

nullable, value of this type can be either null or 'a this type is the same as type t in Null

type +'a undefined

value of this type can be either undefined or 'a this type is the same as type t in Undefined

type +'a nullable

value of this type can be undefined, null or 'a this type is the same as type t n Null_undefined

type +'a null_undefined = 'a nullable
module Array2 : sig ... end

Provide bindings to Js array

module Exn : sig ... end

Provide utilities for dealing with Js exceptions

module Vector : sig ... end
module String : sig ... end

Provide bindings to JS string

module TypedArray2 : sig ... end

Provide bindings for JS typed array

nested modules
module Null : sig ... end

Provide utilities around 'a null

module Undefined : sig ... end

Provide utilities around undefined

module Nullable : sig ... end

Provide utilities around null_undefined

module Null_undefined : sig ... end
module Array : sig ... end

Provide bindings to Js array

module String2 : sig ... end

Provide bindings to JS string

module Re : sig ... end

Provide bindings to Js regex expression

module Promise : sig ... end

Provide bindings to JS promise

module Date : sig ... end

Provide bindings for JS Date

module Dict : sig ... end

Provide utilities for JS dictionary object

module Global : sig ... end

Provide bindings to JS global functions in global namespace

module Json : sig ... end

Provide utilities for json

module Math : sig ... end

Provide bindings for JS Math object

module Obj : sig ... end
module Typed_array : sig ... end

Provide bindings for JS typed array

module Types : sig ... end

Provide utilities for manipulating JS types

module Float : sig ... end

Provide utilities for JS float

module Int : sig ... end

Provide utilities for int

module Bigint : sig ... end

Provide utilities for bigint

module Option : sig ... end

Provide utilities for option

module Result : sig ... end

Define the interface for result

module List : sig ... end

Provide utilities for list

module Console : sig ... end
module Set : sig ... end

Provides bindings for ES6 Set

module WeakSet : sig ... end

Provides bindings for ES6 WeakSet

module Map : sig ... end

Provides bindings for ES6 Map

module WeakMap : sig ... end

Provides bindings for ES6 WeakMap