Skip to content

Module APIs

Jason Bertsche edited this page Jun 1, 2017 · 9 revisions

array

all :: forall t. (t -> Boolean) -> Array t -> Boolean

Whether or not the predicate (1) holds for all values within the array (2)

concat :: forall t. Array t -> Array t -> Array t

The first array (1) with the values of the second array (2) sequentially appended to its end

contains :: forall t. t -> Array t -> Boolean

Whether or not the array (2) contains the element (1)

countBy :: forall t. (t -> String) -> Array t -> Object Number

An object, such that the function (1) maps the items of the array (2) to the object's keys, and any given key's corresponding value is the number of items from the array that mapped to that key

difference :: forall t. Array t -> Array t -> Array t

A copy of the first array (1), with the items of the second array (2) removed from it

exists :: forall t. (t -> Boolean) -> Array t -> Boolean

Whether or not any item within the array (2) meets the given criteria (1)

filter :: forall t. (t -> Boolean) -> Array t -> Array t

A copy of the array (2), containing only the items that meet the criteria (1)

find :: forall t. (t -> Boolean) -> Array t -> Maybe t

A Something containing the first item within the array (2) that meets the criteria (1); None if no such thing can be found

findIndex :: forall t. (t -> Boolean) -> Array t -> Maybe Number

A Something containing the first index at which an item in the array (2) meets the criteria (1); None if no such thing can be found

flatMap :: forall t u. (t -> Array u) -> Array t -> Array u

Functionally, a copy of the array (2) with each item mapped according to the function (1), and then subjected to a one-level flattening; equivalent to a monadic bind operation

flattenDeep :: forall t u. Array t -> Array u

A deep flattening of input array (1), such that it has no remaining elements that are arrays

foldl :: forall t u. (u,t -> u) -> u -> Array t -> u

A left fold of the array (3), such that the combination function (1) is applied to each item of the array, from left to right, building an accumulator from the initial value (2)

forEach :: forall t. (t -> ()) -> Array t -> ()

The value undefined, but not before running the function (1) on each element of the array (2) sequentially

head :: forall t. Array t -> Maybe t

If the array isn't empty, a Something containing the first item of the array (1); otherwise, None

isEmpty :: forall t. Array t -> Boolean

Whether or not the input array (1) contains any elements

item :: forall t. Number -> Array t -> Maybe t

A Something containing the item in the array (2) at that index (1), if the index is in-bounds; otherwise, None

last :: forall t. Array t -> t

The last item of the array (1); undefined if an empty array

length :: forall t. Array t -> Number

The number of items in the input array (1)

map :: forall t u. (t -> u) -> Array t -> Array u

A copy of the array (2) with the mapping function (1) applied to each item

maxBy :: forall t. (t -> Number) -> Array t -> Maybe t

A Something containing the item of the array (2) that generates the largest number when the function (1) is applied to it; None if the array is empty

reverse :: forall t. Array t -> Array t

A new array, which consists of the items from the input array (1) in reverse order

singleton :: forall t. t -> Array t

An array whose one item is the argument

sortBy :: forall t. (t -> Comparable) -> Array t -> Array t

A copy of the array (2), sorted from least to greatest by the criteria (1)

Note: Comparable includes all values for which the standard JavaScript comparison operators are defined

sortedIndexBy :: forall t. (t -> Comparable) -> Array t -> t -> Number

The lowest index at which the item (3) can be inserted into the array (2) while still maintaining the sort order, as defined by the sorting function (1)

Note: Assumes that the array is already sorted in terms of the sorting function

Note: Comparable includes all values for which the standard JavaScript comparison operators are defined

tail :: forall t. Array t -> Array t

A sequential array of all items of the input array (1) but the first item

toObject :: forall t. Array (String, t) -> Object t

Treating each pair in the input array (1) as a key-value pair, an object composed from mapping each of those keys to its corresponding value

unique :: forall t. Array t -> Array t

A copy of the input array (1) with all redundant items removed

uniqueBy :: forall t u. (t -> u) -> Array t -> Array t

A copy of the input array (2) with all redundant items removed, where each item's identity is defined by the mapping function (1)

zip :: forall t u. Array t -> Array u -> Array (t, u)

An array where each item at index n is the nth item of the first array (1), paired with the nth item of the second array (2), where the maximum n is the lowest maximum n between the two arrays; items in either array that are at indexes above the maximum n are dropped

equals

arrayEquals :: forall t. Array t -> Array t -> Boolean

Whether or not the two arguments are (deep) equivalent

booleanEquals :: Boolean -> Boolean -> Boolean

Whether or not the two arguments are equivalent

eq :: Any -> Any -> Boolean

Whether or not the two arguments are (deep) equivalent

numberEquals :: Number -> Number -> Boolean

Whether or not the two arguments are equivalent

objectEquals :: forall t. Object t -> Object t -> Boolean

Whether or not the two arguments are (deep) equivalent

stringEquals :: String -> String -> Boolean

Whether or not the two arguments are equivalent

function

apply :: forall t u. (t -> u) -> t -> u

The result of calling the function (1) with the value (2) as its sole argument.

constantly :: forall t. t -> Unit -> t

A function that always returns the argument

curry :: Function? -> (? -> ?)

The argument, but where the argument required a single n-argument application, instead requiring n single-argument applications

flip :: forall t u v. (t -> u -> v) -> (u -> t -> v)

The input binary function with its two arguments flipped in order

id :: forall t. t -> t

The value passed in

pipeline :: forall t. (t -> t)* -> (t -> t)

A function that is the left-to-right composition of all functions passed as arguments

tee :: forall t u v. (t -> u) -> (t -> v) -> t -> (u, v)

A pair, where the first item is the result of applying the item (3) to the first function (1), and the second item is the result of applying the item (3) to the second function (2)

uncurry :: (? -> ?) -> Function?

The argument, but, where the argument required n single-argument applications, instead requiring a single n-argument application

maybe

None :: Maybe Nothing

An empty Maybe

Something :: forall t. t -> Maybe t

A Maybe containing the argument

filter :: forall t. (t -> Boolean) -> Maybe t -> Maybe t

If the supplied value (2) is a Something that contains a value that evaluates to false when the predicate (1) is run on it, then None; otherwise, the supplied value

flatMap :: forall t u. (t -> Maybe u) -> Maybe t -> Maybe u

If the supplied value (2) is a Something, then the result of the contained value of the original Something applied to the function (1); otherwise, None

fold :: forall t u. (Unit -> u) -> (t -> u) -> Maybe t -> u

If the supplied value (3) is a Something, then the result of applying its contained value to the mapping function (2); otherwise, the result of running the default function (1)

isSomething :: Maybe _ -> Boolean

Whether or not the argument is a Something

map :: forall t u. (t -> u) -> Maybe t -> Maybe u

If the supplied value (2) is a Something, then a new Something that contains the result of the contained value of the original Something applied to the function (1); otherwise, None

maybe :: forall t. t -> Maybe t

If the supplied value (1) is nullary (e.g. null, undefined), then None; otherwise a Something containing the value

toArray :: forall t. Maybe t -> Array t

If the argument is a Something, then an array whose single item is that contained in the Something; otherwise, an empty array

number

multiply :: Number -> Number -> Number

The product of the two arguments

plus :: Number -> Number -> Number

The sum of the two arguments

rangeTo :: Number -> Number -> Array Number

The sequence of numbers from the start (1) up to (and including) the end (2)

rangeUntil :: Number -> Number -> Array Number

The sequence of numbers from the start (1) up to (but not including) the end (2)

object

clone :: forall t. Object t -> Object t

A shallow copy of the input object

keys :: Object _ -> Array String

The enumerable field names of the input object

lookup :: forall t. String -> Object t -> Maybe t

A Something containing the value in the object (2) for that key (1), if the object is defined for that key; otherwise, None

pairs :: forall t. Object t -> Array (String, t)

The key-value pairs of all enumerable entries in the input object

values :: forall t. Object t -> Array t

The enumerable field values of the input object

type

isArray :: Any -> Boolean

Whether or not the input is an array

isBoolean :: Any -> Boolean

Whether or not the input is a boolean

isFunction :: Any -> Boolean

Whether or not the input is a function

isNumber :: Any -> Boolean

Whether or not the input is a number

isObject :: Any -> Boolean

Whether or not the input is an object

isString :: Any -> Boolean

Whether or not the input is a string

Clone this wiki locally
You can’t perform that action at this time.