Code coverage report for src/max.js

Statements: 100% (31 / 31)      Branches: 100% (18 / 18)      Functions: 100% (2 / 2)      Lines: 100% (14 / 14)      Ignored: 4 statements, 4 branches     

All files » src/ » max.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 25 26      1 14 14 14 14 14   14 42   42 16 16     42     14        
import identity from './identity';
 
 
function max(xs, iteratee=identity, thisArg=undefined) {
    let fn = thisArg ? iteratee.bind(thisArg) : iteratee;
    let result = Number.NEGATIVE_INFINITY;
    let resultValue = Number.NEGATIVE_INFINITY;
    let i = 0;
    let value;
 
    for (let x of xs) {
        value = fn(x, i, xs);
 
        if (value > resultValue) {
            resultValue = value;
            result = x;
        }
 
        i += 1;
    }
 
    return result;
}
 
export default max;