All files / src/lib/util arraysHaveSameItems.ts

100% Statements 8/8
100% Branches 1/1
100% Functions 2/2
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 1365x 17x 17x   17x 5x     12x 17x      
export const arraysHaveSameItems = <T>(a: T[], b: T[]): boolean => {
    const setA = new Set(a);
    const setB = new Set(b);
 
    if (setA.size !== setB.size) {
        return false;
    }
 
    return [...setA].every((itemA) => {
        return setB.has(itemA);
    });
};