all files / popper/utils/ find.js

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