1
|
import { Pipe, PipeTransform } from '@angular/core';
|
2
|
import { RepositorySnippet } from '../../domain/typeScriptClasses';
|
3
|
|
4
|
@Pipe ({
|
5
|
name: 'repoFilter'
|
6
|
})
|
7
|
|
8
|
export class RepoFilter implements PipeTransform {
|
9
|
transform (items: RepositorySnippet[], searchTerm: string): any[] {
|
10
|
if (!items) { return []; }
|
11
|
if (!searchTerm) { return items; }
|
12
|
|
13
|
searchTerm = searchTerm.trim();
|
14
|
searchTerm = searchTerm.toLowerCase();
|
15
|
|
16
|
return items.filter(
|
17
|
repo => {
|
18
|
return repo.officialname.toLowerCase().includes(searchTerm);
|
19
|
}
|
20
|
);
|
21
|
}
|
22
|
}
|
23
|
|