UNPKG

mini-state-machine

Version:
10 lines (9 loc) 252 B
export function find(arr, cb, options = {}) { const { index = false } = options; for (let i = 0; i < arr.length; i += 1) { if (cb(arr[i], i)) { return index ? i : arr[i]; } } return index ? -1 : undefined; }