rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
821 lines (359 loc) • 9.11 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [rc-js-util](./rc-js-util.md) > [\_Array](./rc-js-util._array.md)
## \_Array class
Utilities that apply to `Array` and `ArrayLike`<!-- -->.
**Signature:**
```typescript
export declare class _Array
```
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[addToSet](./rc-js-util._array.addtoset.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayAddToSet
</td><td>
Adds the items in an array to the set.
</td></tr>
<tr><td>
[binaryFindInsertionIndex](./rc-js-util._array.binaryfindinsertionindex.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayBinaryFindInsertionIndex
</td><td>
Performs a bisection search of an 'indexable' object such that if the value were inserted, it would remain in order.
</td></tr>
<tr><td>
[binaryIndexOf](./rc-js-util._array.binaryindexof.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayBinaryIndexOf
</td><td>
Performs a bisection search of an 'indexable' object, i.e. can be accessed by index, for example `Array`<!-- -->. Custom data structures are also supported.
</td></tr>
<tr><td>
[binaryLastIndexOf](./rc-js-util._array.binarylastindexof.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayBinaryLastIndexOf
</td><td>
Performs a bisection search of an 'indexable' object, i.e. can be accessed by index, for example `Array`<!-- -->. Custom data structures are also supported.
</td></tr>
<tr><td>
[collect](./rc-js-util._array.collect.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayCollect
</td><td>
Like `Array.reduce` but without the requirement to return the value in the callback.
</td></tr>
<tr><td>
[compact](./rc-js-util._array.compact.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayCompact
</td><td>
Strips null and undefined items from arrays (non mutative).
</td></tr>
<tr><td>
[compactMap](./rc-js-util._array.compactmap.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayCompactMap
</td><td>
Like \_Array.map but where the callback returns null it will be omitted from the result.
</td></tr>
<tr><td>
[contains](./rc-js-util._array.contains.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayContains
</td><td>
Returns true if the item is present in the list (=== equality test).
</td></tr>
<tr><td>
[copyInto](./rc-js-util._array.copyinto.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayCopyInto
</td><td>
Make an array contain the same items as another.
</td></tr>
<tr><td>
[emptyArray](./rc-js-util._array.emptyarray.md)
</td><td>
`static`
`readonly`
</td><td>
readonly \[\]
</td><td>
An empty readonly array, useful to avoid GC pressure.
</td></tr>
<tr><td>
[flatMap](./rc-js-util._array.flatmap.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayFlatMap
</td><td>
Iterate over `ArrayLike` calling a callback against it, the callback returns `ArrayLike` which is concatenated into a single `Array`<!-- -->.
</td></tr>
<tr><td>
[forEach](./rc-js-util._array.foreach.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayForEach
</td><td>
Like `Array.forEach`<!-- -->.
</td></tr>
<tr><td>
[forEachRange](./rc-js-util._array.foreachrange.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayForEachRange
</td><td>
Like [arrayForEach()](./rc-js-util.arrayforeach.md) with integer range as input.
</td></tr>
<tr><td>
[generateRange](./rc-js-util._array.generaterange.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayGenerateRange
</td><td>
Generates a range of integers output in an `Array`<!-- -->.
</td></tr>
<tr><td>
[index](./rc-js-util._array.index.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayIndex
</td><td>
Populates a `Map` given a key creating function and `ArrayLike`<!-- -->.
</td></tr>
<tr><td>
[insertAtIndex](./rc-js-util._array.insertatindex.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayInsertAtIndex
</td><td>
Modifies input array by inserting at given index.
</td></tr>
<tr><td>
[intersect](./rc-js-util._array.intersect.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayIntersect
</td><td>
Given two `ArrayLike`<!-- -->, provides the items common between them in an `Array`<!-- -->.
</td></tr>
<tr><td>
[isArray](./rc-js-util._array.isarray.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayIsArray
</td><td>
Checks if the parameter is an instance of `Array` or is a view of `ArrayBuffer`<!-- -->.
</td></tr>
<tr><td>
[isNotEmpty](./rc-js-util._array.isnotempty.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayIsNotEmpty
</td><td>
Returns true if the argument is not null, undefined or empty. Type narrows to `TArray` where true.
</td></tr>
<tr><td>
[last](./rc-js-util._array.last.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayLast
</td><td>
Gets the last value in `ArrayLike`<!-- -->.
</td></tr>
<tr><td>
[map](./rc-js-util._array.map.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayMap
</td><td>
Like `Array.map`<!-- -->.
</td></tr>
<tr><td>
[mapRange](./rc-js-util._array.maprange.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayMapRange
</td><td>
Like [arrayMap()](./rc-js-util.arraymap.md) with integer range as input.
</td></tr>
<tr><td>
[max](./rc-js-util._array.max.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayMax
</td><td>
Find the largest number in an array, if the array is empty the return is -Infinity.
</td></tr>
<tr><td>
[min](./rc-js-util._array.min.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayMin
</td><td>
Find the smallest number in an array, if the array is empty the return is Infinity.
</td></tr>
<tr><td>
[normalizeEmptyToUndefined](./rc-js-util._array.normalizeemptytoundefined.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayNormalizeEmptyToUndefined
</td><td>
Replaces length 0 `ArrayLike` with `undefined`<!-- -->.
</td></tr>
<tr><td>
[normalizeNullishToEmpty](./rc-js-util._array.normalizenullishtoempty.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayNormalizeNullishToEmpty
</td><td>
Replaces `null` / `undefined` with an empty `Array`<!-- -->.
</td></tr>
<tr><td>
[pushUnique](./rc-js-util._array.pushunique.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayPushUnique
</td><td>
Like `Array.push` but checks if the value is unique first.
</td></tr>
<tr><td>
[removeMany](./rc-js-util._array.removemany.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayRemoveMany
</td><td>
Removes each item in `itemsToRemove` from `items` (including any repeated items).
</td></tr>
<tr><td>
[removeOne](./rc-js-util._array.removeone.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayRemoveOne
</td><td>
Removes either 0 or one item from items, even if itemToRemove appears more than once.
</td></tr>
<tr><td>
[replaceOne](./rc-js-util._array.replaceone.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayReplaceOne
</td><td>
Replaces the first match of itemToRemove with replaceWith.
</td></tr>
<tr><td>
[setDifference](./rc-js-util._array.setdifference.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arraySetDifference
</td><td>
returns items in A not in B.
</td></tr>
<tr><td>
[symmetricDifference](./rc-js-util._array.symmetricdifference.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arraySymmetricDifference
</td><td>
Returns those items in A not in B, and those items in B not in A.
</td></tr>
<tr><td>
[union](./rc-js-util._array.union.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayUnion
</td><td>
Given an `ArrayLike` of `ArrayLike`<!-- -->, provides all unique items in an `Array`<!-- -->.
</td></tr>
<tr><td>
[unique](./rc-js-util._array.unique.md)
</td><td>
`static`
`readonly`
</td><td>
typeof arrayUnique
</td><td>
Creates a new array with no duplicates, using standard object equality.
</td></tr>
</tbody></table>