Code coverage report for array/find.js

Statements: 100% (12 / 12)      Branches: 100% (2 / 2)      Functions: 100% (3 / 3)      Lines: 100% (11 / 11)     

All files » array/ » find.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 251           1 14     14 32 32 14 14   18   14     1      
define(['./some'], function (some) {
 
    /**
     * Returns first item that matches criteria
     * @version 0.2.0 (2012/06/07)
     */
    function find(arr, iterator, thisObj){
        var needle,
            i = 0, n = arr.length,
            val;
        while (i < n){
            val = arr[i];
            if (iterator.call(thisObj, val, i, arr)) {
                needle = val;
                break;
            }
            i += 1;
        }
        return needle;
    }
 
    return find;
 
});