Debian Codegraph @

packages/popper/src/utils/find.js

raw
1 /**
2 * Mimics the `find` method of Array
3 * @method
4 * @memberof Popper.Utils
5 * @argument {Array} arr
6 * @argument prop
7 * @argument value
8 * @returns index or -1
9 */
10 export default function find(arr, check) {
11 // use native find if supported
12 if (Array.prototype.find) {
13 return arr.find(check);
14 }
15
16 // use `filter` to obtain the same behavior of `find`
17 return arr.filter(check)[0];
18 }