All files / src/helpers array.ts

88.88% Statements 8/9
0% Branches 0/4
100% Functions 4/4
85.71% Lines 6/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 14 15 16 17 18 19 20 21 22  11x 16x 9x       138x               848x     665x      
export function intersect (array1: any[] = [], array2: any[] = []): any[] {
  return array1.filter(value =>
    array2.includes(value)
  ).filter((element, index, arr) => arr.indexOf(element) === index);
}
 
export function difference (array1: any[] = [], array2: any[] = []): any[] {
  return array2.filter(value => !array1.includes(value));
}
 
export function lastEntry (array: any[]): any {
  return array[array.length - 1];
}
 
export function removeEntry (map: any[], key: any): void {
  const stepIndex = map.findIndex(entry => entry === key);
  if (stepIndex > -1) {
    // delete by reference
    map.splice(stepIndex, 1);
  }
}