arr-helper-functions / Exports
- areInAnyArray
- areInArray
- areInSameArray
- distinctValues
- filterFalsyValues
- getBestSortingFunction
- getFirstAndLastElement
- isEmpty
- isInAnyArray
- isInArray
- isNotEmpty
- isNotInArray
- sortArray
▸ areInAnyArray(items
, arrays
): boolean
Checks if items are found in any of the provided arrays
Name | Type | Description |
---|---|---|
items |
ElementToLookFor [] |
Items to look for |
arrays |
any [][] |
Arrays to look in |
boolean
Returns false as soon as an item isn't found in any array
Export
▸ areInArray(elements
, array
): boolean
Checks if all the items is found in the same array
Name | Type | Description |
---|---|---|
elements |
ElementToLookFor [] |
Items to look for |
array |
any [] |
Array to look in |
boolean
True if all elements are found. As soon as an item isn't found, returns false
Export
▸ areInSameArray(items
, arrays
): boolean
Checks if all items are found in same array
Name | Type | Description |
---|---|---|
items |
ElementToLookFor [] |
Items to look for |
arrays |
any [][] |
Arrays to look in |
boolean
Returns true only if all items are found in the same array
Export
▸ distinctValues(array
, property?
): any
[]
Gets the distinct values of an array
Name | Type | Description |
---|---|---|
array |
any [] |
Array to find unique values of |
property? |
string | AccessorFunction |
Property to map or accesor function to use to obtain the desired value |
any
[]
The unique array of values
Export
▸ filterFalsyValues(array
, includeZeros?
): any
[]
Returns a new array without falsy values false, null, and undefined will be removed from an array
Name | Type | Default value | Description |
---|---|---|---|
array |
any [] |
undefined |
Array to filter |
includeZeros? |
boolean |
false |
Whether to consider 0s as falsy |
any
[]
Filtered array
Export
▸ getBestSortingFunction(array
): SortingFunction
Gets the most appropriate sort depending on array content
Name | Type | Description |
---|---|---|
array |
any [] |
Array to analyse |
The function to pass the sort() method
Export
▸ getFirstAndLastElement<T
>(array
): [T
, T
]
Gets the first and last elements of an array
Name |
---|
T |
Name | Type | Description |
---|---|---|
array |
T [] |
The array to get elements of |
[T
, T
]
The first and last elements
Export
▸ isEmpty(array
): boolean
Checks if array is empty
Name | Type | Description |
---|---|---|
array |
any [] |
Array to check length of |
boolean
True if array.length === 0
Export
▸ isInAnyArray(element
, arrays
): boolean
Checks if an item is found in any of the provided arrays
Name | Type | Description |
---|---|---|
element |
ElementToLookFor |
Item to look for |
arrays |
any [][] |
Arrays to look in |
boolean
Returns true if the item is found in any of the arrays
Export
▸ isInArray(element
, array
): boolean
Returns whether an element is found in an array or not
Name | Type | Description |
---|---|---|
element |
ElementToLookFor |
Item to look for |
array |
any [] |
Array to look in |
boolean
Whether an element is found in an array or not
Export
▸ isNotEmpty(array
): boolean
Checks if array is not empty
Name | Type | Description |
---|---|---|
array |
any [] |
Array to check if empty |
boolean
True if array.length > 0
Export
▸ isNotInArray(element
, array
): boolean
Returns whether an element is not found in an array or not
Name | Type | Description |
---|---|---|
element |
ElementToLookFor |
Item to look for |
array |
any [] |
Array to look in |
boolean
Whether an element is not found in an array or not
Export
▸ sortArray(array
): any
[]
Clones array and sorts it with most appropriate sorting function
Name | Type | Description |
---|---|---|
array |
any [] |
Array to sort |
any
[]
Cloned and sorted array
Export