shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
findAll
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.array
This function is a subset of the native “find” but it returns all the items that match the check function. It returns an array of objects, each containing the:
- index: the position in the array
- value: the actual value at this position
Params
- ar*-Array
The array in which to search for an item
- check*-Function
The check function to test if the element is the searched one
Return
- -TFindAllResult[]|null
An array of objects containing the index and value of the found items, or null if nothing found
Example
import { findAll } from '@blackbyte/sugar/array';
findAll(['hello','world'], (item: any) => item === 'world')
[
{
index: 1,
value: 'world'
}
]Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space