Code coverage report for src/min.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/ » min.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 6 6 6 6 6   6 16   16 5 5     16     6        
import identity from './identity';
 
 
function min(xs, iteratee=identity, thisArg=undefined) {
    let fn = thisArg ? iteratee.bind(thisArg) : iteratee;
    let result = Number.POSITIVE_INFINITY;
    let resultValue = Number.POSITIVE_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 min;