All files / src/utils setUtils.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 5/5
100% Lines 6/6

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 14 15 16 17 18 19 20 21 22 23 24 25 26 27                  3x 11x           3x 8x           3x 36x    
/*!
 * Copyright 2020 Cognite AS
 */
 
// Functions from https://exploringjs.com/impatient-js/ch_sets.html#missing-set-operations
 
/**
 * Returns set combined of items in both sets.
 */
export function setUnion<T>(left: Set<T>, right: Set<T>): Set<T> {
  return new Set<T>([...left, ...right]);
}
 
/**
 * Returns elements in left that is also in right.
 */
export function setIntersection<T>(left: Set<T>, right: Set<T>): Set<T> {
  return new Set<T>([...left].filter(x => right.has(x)));
}
 
/**
 * Returns elements in left that are not in right.
 */
export function setDifference<T>(left: Set<T>, right: Set<T>): Set<T> {
  return new Set<T>([...left].filter(x => !right.has(x)));
}