Module Js.Array2

Provide bindings to Js array

JavaScript Array API

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

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

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

ES2016

let indexOf: t('a) => 'a => int;
let indexOfFrom: t('a) => 'a => from:int => int;
let joinWith: t('a) => string => string;
let lastIndexOf: t('a) => 'a => int;
let lastIndexOfFrom: t('a) => 'a => from:int => int;
let slice: t('a) => start:int => end_:int => t('a);
let copy: t('a) => t('a);
let sliceFrom: t('a) => int => t('a);
let toString: t('a) => string;
let toLocaleString: t('a) => string;
let every: t('a) => ('a => bool) => bool;
let everyi: t('a) => ('a => int => bool) => bool;
let filter: t('a) => ('a => bool) => t('a);

should we use bool or boolean seems they are intechangeable here

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