Module Js.Array

Provide bindings to Js array

JavaScript Array API

type 'a t = 'a array
type 'a array_like
val from : 'a array_like -> 'a array
val fromMap : 'a array_like -> ('a -> 'b) -> 'b array
val isArray : 'a -> bool
val length : 'a array -> int
val copyWithin : to_:int -> 'a t as 'this -> 'this
val copyWithinFrom : to_:int -> from:int -> 'a t as 'this -> 'this
val copyWithinFromRange : to_:int -> start:int -> end_:int -> 'a t as 'this -> 'this
val fillInPlace : 'a -> 'a t as 'this -> 'this
val fillFromInPlace : 'a -> from:int -> 'a t as 'this -> 'this
val fillRangeInPlace : 'a -> start:int -> end_:int -> 'a t as 'this -> 'this
val pop : 'a t as 'this -> 'a option

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push

val push : 'a -> 'a t as 'this -> int
val pushMany : 'a array -> 'a t as 'this -> int
val reverseInPlace : 'a t as 'this -> 'this
val shift : 'a t as 'this -> 'a option
val sortInPlace : 'a t as 'this -> 'this
val sortInPlaceWith : ('a -> 'a -> int) -> 'a t as 'this -> 'this
val spliceInPlace : pos:int -> remove:int -> add:'a array -> 'a t as 'this -> 'this
val removeFromInPlace : pos:int -> 'a t as 'this -> 'this
val removeCountInPlace : pos:int -> count:int -> 'a t as 'this -> 'this
val unshift : 'a -> 'a t as 'this -> int
val unshiftMany : 'a array -> 'a t as 'this -> int
val append : 'a -> 'a t as 'this -> 'this
  • deprecated append is not type-safe. Use `concat` instead, and see #1884
val concat : 'this -> 'a t as 'this -> 'this
val concatMany : 'this array -> 'a t as 'this -> 'this
val includes : 'a -> 'a t as 'this -> bool

ES2016

val indexOf : 'a -> 'a t as 'this -> int
val indexOfFrom : 'a -> from:int -> 'a t as 'this -> int
val join : 'a t -> string
  • deprecated please use joinWith instead
val joinWith : string -> 'a t as 'this -> string
val lastIndexOf : 'a -> 'a t as 'this -> int
val lastIndexOfFrom : 'a -> from:int -> 'a t as 'this -> int
val lastIndexOf_start : 'a -> 'a t as 'this -> int
  • deprecated Please use `lastIndexOf
val slice : start:int -> end_:int -> 'a t as 'this -> 'this
val copy : 'a t as 'this -> 'this
val slice_copy : unit -> 'a t as 'this -> 'this
  • deprecated Please use `copy`
val sliceFrom : int -> 'a t as 'this -> 'this
val slice_start : int -> 'a t as 'this -> 'this
  • deprecated Please use `sliceFrom`
val toString : 'a t as 'this -> string
val toLocaleString : 'a t as 'this -> string
val every : ('a -> bool) -> 'a t as 'this -> bool
val everyi : ('a -> int -> bool) -> 'a t as 'this -> bool
val filter : ('a -> bool) -> 'a t as 'this -> 'this

should we use bool or boolean seems they are intechangeable here

val filteri : ('a -> int -> bool) -> 'a t as 'this -> 'this
val find : ('a -> bool) -> 'a t as 'this -> 'a option
val findi : ('a -> int -> bool) -> 'a t as 'this -> 'a option
val findIndex : ('a -> bool) -> 'a t as 'this -> int
val findIndexi : ('a -> int -> bool) -> 'a t as 'this -> int
val forEach : ('a -> unit) -> 'a t as 'this -> unit
val forEachi : ('a -> int -> unit) -> 'a t as 'this -> unit
val map : ('a -> 'b) -> 'a t as 'this -> 'b t
val mapi : ('a -> int -> 'b) -> 'a t as 'this -> 'b t
val reduce : ('b -> 'a -> 'b) -> 'b -> 'a t as 'this -> 'b
val reducei : ('b -> 'a -> int -> 'b) -> 'b -> 'a t as 'this -> 'b
val reduceRight : ('b -> 'a -> 'b) -> 'b -> 'a t as 'this -> 'b
val reduceRighti : ('b -> 'a -> int -> 'b) -> 'b -> 'a t as 'this -> 'b
val some : ('a -> bool) -> 'a t as 'this -> bool
val somei : ('a -> int -> bool) -> 'a t as 'this -> bool
val unsafe_get : 'a array -> int -> 'a
val unsafe_set : 'a array -> int -> 'a -> unit