Code coverage report for src/findWhere.js

Statements: 100% (35 / 35)      Branches: 100% (16 / 16)      Functions: 100% (1 / 1)      Lines: 100% (11 / 11)      Ignored: 8 statements, 4 branches     

All files » src/ » findWhere.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221 5   5 13   13 15 9   9       13 4            
function findWhere(xs, query) {
    let props = Object.getOwnPropertyNames(query);
 
    for (let x of xs) {
        let match = true;
 
        for (let prop of props) {
            if (query[prop] !== x[prop]) {
                match = false;
 
                break;
            }
        }
 
        if (match) {
            return x;
        }
    }
}
 
export default findWhere;