It seems like you are looking to filter an array based on specific values, similar to the example below :
playground
type DataSource = {
FirstName: string;
LastName: string;
};
class Foo {
public dataSource: DataSource[] = [{
FirstName: 'Obiwan',
LastName: 'Kenobi',
}, {
FirstName: 'Bob',
LastName: 'Franklin',
}, {
FirstName: 'Anakin',
LastName: 'skywalker',
}];
public performFilter(filterBy: string) {
const toFilterBy = filterBy.toLocaleLowerCase();
return this.dataSource.filter((data: DataSource) => ([
'FirstName',
'LastName',
] as (keyof DataSource)[]).some(x => data[x] && data[x].toLocaleLowerCase().indexOf(toFilterBy) !== -1));
}
}
const foo = new Foo();
console.log('------- Before', foo.dataSource);
console.log('------- After', foo.performFilter('Obiwan'));