All files / src/app/shared/pipes filter.pipe.ts

100% Statements 15/15
100% Branches 6/6
100% Functions 4/4
100% Lines 13/13

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 2699x         99x 99x 4x 9x   9x 12x 3x     9x 9x 4x       9x     99x  
import { Pipe, PipeTransform } from '@angular/core';
 
@Pipe({
  name: 'filter'
})
export class FilterPipe implements PipeTransform {
  transform(value: any, args?: any): any {
    return value.filter((row) => {
      let result = true;
 
      args.forEach((filter) => {
        if (!filter.value) {
          return;
        }
 
        result = result && filter.applyFilter(row, filter.value);
        if (!result) {
          return result;
        }
      });
 
      return result;
    });
  }
}