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

100% Statements 13/13
100% Branches 2/2
100% Functions 4/4
100% Lines 11/11

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
    2693x

    93x
    93x
    4x
    9x

    9x

    3x

    9x

    4x

    9x

    93x
     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;
        });
      }
    }