All files / src/utils shallow-compare.ts

100% Statements 11/11
100% Branches 6/6
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 1437x 30x   22x   22x   21x 34x     12x    
export function shallowCompare(next: any[], prev: any[] | null) {
    if (!Array.isArray(prev)) return false
 
    const prevLength = prev.length
 
    if (prevLength !== next.length) return false
 
    for (let i = 0; i < prevLength; i++) {
        if (prev[i] !== next[i]) return false
    }
 
    return true
}