js-util

Home > rc-js-util > _Array

_Array class

Utilities that apply to Array and ArrayLike.

Signature:

export declare class _Array 

Properties

Property Modifiers Type Description
addToSet static typeof arrayAddToSet Adds the items in an array to the set.
binaryIndexOf static typeof arrayBinaryIndexOf Performs a bisection search of an ‘indexable’ object, i.e. can be accessed by index, for example Array. Custom data structures are also supported.
binaryLastIndexOf static typeof arrayBinaryLastIndexOf Performs a bisection search of an ‘indexable’ object, i.e. can be accessed by index, for example Array. Custom data structures are also supported.
collect static typeof arrayCollect Like Array.reduce but without the requirement to return the value in the callback.
compact static typeof arrayCompact Strips null and undefined items from arrays (non mutative).
compactMap static typeof arrayCompactMap Like _Array.map but where the callback returns null it will be omitted from the result.
contains static typeof arrayContains Returns true if the item is present in the list (=== equality test).
copyInto static typeof arrayCopyInto Make an array contain the same items as another.
emptyArray static readonly [] An empty readonly array, useful to avoid GC pressure.
flatMap static typeof arrayFlatMap Iterate over ArrayLike calling a callback against it, the callback returns ArrayLike which is concatenated into a single Array.
forEach static typeof arrayForEach Like Array.forEach.
forEachRange static typeof arrayForEachRange Like arrayForEach() with integer range as input.
generateRange static typeof arrayGenerateRange Generates a range of integers output in an Array.
index static typeof arrayIndex Populates a Map given a key creating function and ArrayLike.
insertAtIndex static typeof arrayInsertAtIndex Modifies input array by inserting at given index.
intersect static typeof arrayIntersect Given two ArrayLike, provides the items common between them in an Array.
isArray static typeof arrayIsArray Checks if the parameter is an instance of Array or is a view of ArrayBuffer.
isNotEmpty static typeof arrayIsNotEmpty Returns true if the argument is not null, undefined or empty. Type narrows to TArray where true.
last static typeof arrayLast Gets the last value in ArrayLike.
map static typeof arrayMap Like Array.map.
mapRange static typeof arrayMapRange Like arrayMap() with integer range as input.
max static typeof arrayMax Find the largest number in an array, if the array is empty the return is -Infinity.
min static typeof arrayMin Find the smallest number in an array, if the array is empty the return is Infinity.
normalizeEmptyToUndefined static typeof arrayNormalizeEmptyToUndefined Replaces length 0 ArrayLike with undefined.
normalizeNullishToEmpty static typeof arrayNormalizeNullishToEmpty Replaces null / undefined with an empty Array.
pushUnique static typeof arrayPushUnique Like Array.push but checks if the value is unique first.
removeMany static typeof arrayRemoveMany Removes each item in itemsToRemove from items (including any repeated items).
removeOne static typeof arrayRemoveOne Removes either 0 or one item from items, even if itemToRemove appears more than once.
replaceOne static typeof arrayReplaceOne Replaces the first match of itemToRemove with replaceWith.
setDifference static typeof arraySetDifference returns items in A not in B.
symmetricDifference static typeof arraySymmetricDifference Returns those items in A not in B, and those items in B not in A.
union static typeof arrayUnion Given an ArrayLike of ArrayLike, provides all unique items in an Array.
unique static typeof arrayUnique Creates a new array with no duplicates, using standard object equality.