import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: "filter"
})

export class FilterPipe implements PipeTransform {
    transform(users: any, filter: any) {
        if (filter && Array.isArray(users)) {
            let usersArray = users.filter(user => user.username.toLowerCase().indexOf(filter.username.toLowerCase()) !== -1);
            return usersArray;
        } else {
            return users;
        }
    }
}