Efficient sorted find function, using a heap to efficiently sort until a match is found.
npm install --save heapfind
import heapfind from 'heapfind';
const firstFoo = heapfind(
[
{ index: 3, name: 'foo' },
{ index: 1, name: 'bar' },
{ index: 2, name: 'foo' },
],
(a, b) => a.index - b.index,
({ name }) => name === 'foo'
);
ISC