Wait for a left-most matched promise to be fulfilled
npm install p-find-index

Wait for a left-most matched promise to be fulfilled
``sh`
$ npm i p-find-index
`js
import {
find,
findIndex,
AggregateError,
MatchError
} from 'p-find-index'
import delay from 'delay'
const input = [
delay(100).then(() => 100),
delay(50).then(() => 10),
delay(60).then(() => 90)
]
const matcher = value => value > 50
console.log(await find(input, matcher)) // 100
console.log(await find(input, matcher, {leftMost: false})) // 90
console.log(await findIndex(input, matcher)) // 0
console.log(await findIndex(input, matcher, {leftMost: false})) // 2
`
Returns a cancelable Promise that is fulfilled when the first match is found. If options.leftMost is true, then it will find the left-most match of the iterable.
If you pass in cancelable promises each of which have an cancel() method, that method will be called when the target value has been found and the thenable is still pending.
- iterable Iterable an Iterable collection of thenables/values to wait for.Function
- matcher receives the value resolved by the thenable and returns a boolean whether the value is matched some condition.Object
- options boolean = true`
- leftMost
Exposed for instance checking.
Exposed for instance checking.