1.0.2 • Published 6 years ago
@bemoje/arr-first-where v1.0.2
@bemoje/arr-first-where
Return the first element of an array where the callback returns true.
Version
Travis CI
Dependencies
Stats
Donate
Installation
npm install @bemoje/arr-first-where
npm install --save @bemoje/arr-first-where
npm install --save-dev @bemoje/arr-first-whereUsage
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
})
//=> nullTests
Uses Jest to test module functionality. Run tests to get coverage details.
npm run testAPI
arrFirstWhere
Return the first element of an array where the callback returns true.
Parameters
Returns
any The first element to satisfy the condition
predicate
Type: Function
Parameters
elementany The current array elementindexnumber The current indexarrayArray The array being itereated