Return the first element of an array where the callback returns true.
npm install @bemoje/arr-first-where
npm install --save @bemoje/arr-first-where
npm install --save-dev @bemoje/arr-first-where
import arrFirstWhere from '@bemoje/arr-first-where'
const arr = [1, 2, 3, 4, 5]
arrFirstWhere(arr, (element) => {
return element >= 3
})
//=> 3
arrFirstWhere(arr, (element) => {
return element >= 6
})
//=> null
Uses Jest to test module functionality. Run tests to get coverage details.
npm run test
Return the first element of an array where the callback returns true.
any The first element to satisfy the condition
Type: Function