@@ -175,7 +175,7 @@ export class Manifest {
175
175
}
176
176
get allHandles ( ) {
177
177
// TODO(#4820) Update `reduce` to use flatMap
178
- return [ ... new Set ( this . _findAll ( manifest => manifest . _recipes . reduce ( ( acc , x ) => acc . concat ( x . handles ) , [ ] ) ) ) ] ;
178
+ return this . allRecipes . reduce ( ( acc , x ) => acc . concat ( x . handles ) , [ ] ) ;
179
179
}
180
180
get activeRecipe ( ) {
181
181
return this . _recipes . find ( recipe => recipe . annotation === 'active' ) ;
@@ -312,7 +312,7 @@ export class Manifest {
312
312
return tags . filter ( tag => ! manifest . storeTags . get ( store ) . includes ( tag ) ) . length === 0 ;
313
313
}
314
314
const stores = [ ...this . _findAll ( manifest =>
315
- manifest . _stores . filter ( store => this . _typePredicate ( store , type , subtype ) && tagPredicate ( manifest , store ) ) ) ] ;
315
+ manifest . _stores . filter ( store => this . typesMatch ( store , type , subtype ) && tagPredicate ( manifest , store ) ) ) ] ;
316
316
317
317
// Quick check that a new handle can fulfill the type contract.
318
318
// Rewrite of this method tracked by https://github.com/PolymerLabs/arcs/issues/1636.
@@ -323,16 +323,16 @@ export class Manifest {
323
323
const tags = options . tags || [ ] ;
324
324
const subtype = options . subtype || false ;
325
325
const fates = options . fates || [ ] ;
326
- function tagPredicate ( handle : Handle ) {
327
- return tags . filter ( tag => ! handle . tags . includes ( tag ) ) . length === 0 ;
326
+ function hasAllTags ( handle : Handle ) {
327
+ return tags . every ( tag => handle . tags . includes ( tag ) ) ;
328
328
}
329
- function fatePredicate ( handle : Handle ) {
329
+ function matchesFate ( handle : Handle ) {
330
330
return fates === [ ] || fates . includes ( handle . fate ) ;
331
331
}
332
332
// TODO(#4820) Update `reduce` to use flatMap
333
- return [ ...this . _findAll ( manifest => manifest . _recipes
333
+ return [ ...this . allRecipes
334
334
. reduce ( ( acc , r ) => acc . concat ( r . handles ) , [ ] )
335
- . filter ( h => this . _typePredicate ( h , type , subtype ) && tagPredicate ( h ) && fatePredicate ( h ) ) ) ] ;
335
+ . filter ( h => this . typesMatch ( h , type , subtype ) && hasAllTags ( h ) && matchesFate ( h ) ) ] ;
336
336
}
337
337
findHandlesById ( id : string ) : Handle [ ] {
338
338
return this . allHandles . filter ( h => h . id === id ) ;
@@ -343,7 +343,7 @@ export class Manifest {
343
343
findRecipesByVerb ( verb : string ) {
344
344
return [ ...this . _findAll ( manifest => manifest . _recipes . filter ( recipe => recipe . verbs . includes ( verb ) ) ) ] ;
345
345
}
346
- _typePredicate ( candidate : { type : Type } , type : Type , checkSubtype : boolean ) {
346
+ private typesMatch ( candidate : { type : Type } , type : Type , checkSubtype : boolean ) {
347
347
const resolvedType = type . resolvedType ( ) ;
348
348
if ( ! resolvedType . isResolved ( ) ) {
349
349
return ( type instanceof CollectionType ) === ( candidate . type instanceof CollectionType ) &&
0 commit comments