File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
lesson_26/api/javascript/api_app/src/library Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export class LibraryService {
18
18
19
19
constructor ( id : string ) {
20
20
this . id = id ;
21
- this . searcher = new CatalogSearcher ( this . itemsById . values ( ) ) ;
21
+ this . searcher = new CatalogSearcher ( this . itemsById ) ;
22
22
}
23
23
24
24
getId ( ) : string {
Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ import { SearchCriteria } from './search_criteria';
2
2
import { Searchable } from './searchable' ;
3
3
4
4
export class CatalogSearcher < T extends Searchable > {
5
- private catalog : Iterable < T > ;
5
+ private catalog : ReadonlyMap < string , T > ;
6
6
7
- constructor ( catalog : Iterable < T > ) {
7
+ constructor ( catalog : ReadonlyMap < string , T > ) {
8
8
this . catalog = catalog ;
9
9
}
10
10
11
11
search ( query : SearchCriteria ) : T [ ] {
12
- return [ ...this . catalog ] . filter ( ( item ) => item . matches ( query ) ) ;
12
+ return [ ...this . catalog . values ( ) ] . filter ( ( item ) => item . matches ( query ) ) ;
13
13
}
14
14
}
You can’t perform that action at this time.
0 commit comments