Contains various functions for working with arrays immutably.
Returns true if all value in needles
is contained in haystack
.
Returns true if array contains duplicate instances based on ===
equality checking
Use containsDuplicateValues if you'd rather compare by value.
Returns true if array contains duplicate values.
Returns true if all values in the array are the same. Uses value-based equality checking by default.
Returns a function that cycles through the contents of an array. By default starts at index 0.
Returns a copy of an array with specified length - padded or truncated as needed.
Returns two separate arrays of everything that filter
returns true,
and everything it returns false on.
Yields elements from array
that match a given predicate
, and moreover are between
the given startIndex
(inclusive) and endIndex
(exclusive).
Returns a 'flattened' copy of array, un-nesting arrays one level
Computes the frequency of values by a grouping function.
Groups data by a function grouper
, returning data as a map with string
keys and array values. Multiple values can be assigned to the same group.
Inserts values
at position index
, shuffling remaining
items further down and returning changed result.
Returns an interleaving of two or more arrays. All arrays must be the same length.
Returns the intersection of two arrays: the elements that are in common.
Returns true if the two arrays have the same items at same indexes.
Merges arrays left to right, using the provided
reconcile
function to choose a winner when keys overlap.
Yields pairs made up of overlapping items from the input array.
Reduces in a pairwise fashion.
Returns a random element of an array
Returns a random array index.
Removes an element at index
index from data
, returning the resulting array without modifying the original.
Samples values from an array.
Returns a shuffled copy of the input array.
Sorts an array of objects in ascending order by the given property name, assuming it is a number.
Sorts an array of objects by some named property.
Combines the values of one or more arrays, removing duplicates.
Compares based on a string representation of object. Uses a Set
to avoid unnecessary comparisons, perhaps faster than uniqueDeep
.
Combines the values of one or more arrays, removing duplicates.
Yields all items in the input array for as long as predicate
returns true.
Returns an array with value(s) omitted.
Returns a copy of an input array with undefined values removed.
Zip combines the elements of two or more arrays based on their index.
Function that returns true if a
and b
are considered equal
Returns a result of a merged into b. B is always the 'newer' data that takes precedence.
Similar to Javascript's in-built Array.at function, but allows offsets to wrap.