Code coverage report for src/indexBy.js

Statements: 100% (25 / 25)      Branches: 100% (10 / 10)      Functions: 100% (2 / 2)      Lines: 100% (12 / 12)      Ignored: 4 statements, 3 branches     

All files » src/ » indexBy.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221 7 7 7   7 1   6     7 39   39     7        
function indexBy(xs, iteratee, thisArg) {
    let i = 0;
    let indices = {};
    let fn;
 
    if (typeof iteratee === 'string') {
        fn = x => x[iteratee];
    } else {
        fn = thisArg ? iteratee.bind(thisArg) : iteratee;
    }
 
    for (let x of xs) {
        indices[fn(x, i, xs)] = x;
 
        i += 1;
    }
 
    return indices;
}
 
export default indexBy;