53f22a5f63776c0165246b78970ed5e214bb877f
[platform/framework/web/crosswalk-tizen.git] /
1 var makeIterator = require('../function/makeIterator_');
2
3     /**
4      * Returns the index of the first item that matches criteria
5      */
6     function findIndex(arr, iterator, thisObj){
7         iterator = makeIterator(iterator, thisObj);
8         if (arr == null) {
9             return -1;
10         }
11
12         var i = -1, len = arr.length;
13         while (++i < len) {
14             if (iterator(arr[i], i, arr)) {
15                 return i;
16             }
17         }
18
19         return -1;
20     }
21
22     module.exports = findIndex;
23