Skip to content

Commit 658cb1a

Browse files
committed
implemented more review suggestions
1 parent 0056ee3 commit 658cb1a

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/runtime/manifest.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class Manifest {
175175
}
176176
get allHandles() {
177177
// 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), []);
179179
}
180180
get activeRecipe() {
181181
return this._recipes.find(recipe => recipe.annotation === 'active');
@@ -312,7 +312,7 @@ export class Manifest {
312312
return tags.filter(tag => !manifest.storeTags.get(store).includes(tag)).length === 0;
313313
}
314314
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)))];
316316

317317
// Quick check that a new handle can fulfill the type contract.
318318
// Rewrite of this method tracked by https://github.com/PolymerLabs/arcs/issues/1636.
@@ -323,16 +323,16 @@ export class Manifest {
323323
const tags = options.tags || [];
324324
const subtype = options.subtype || false;
325325
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));
328328
}
329-
function fatePredicate(handle: Handle) {
329+
function matchesFate(handle: Handle) {
330330
return fates === [] || fates.includes(handle.fate);
331331
}
332332
// TODO(#4820) Update `reduce` to use flatMap
333-
return [...this._findAll(manifest => manifest._recipes
333+
return [...this.allRecipes
334334
.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))];
336336
}
337337
findHandlesById(id: string): Handle[] {
338338
return this.allHandles.filter(h => h.id === id);
@@ -343,7 +343,7 @@ export class Manifest {
343343
findRecipesByVerb(verb: string) {
344344
return [...this._findAll(manifest => manifest._recipes.filter(recipe => recipe.verbs.includes(verb)))];
345345
}
346-
_typePredicate(candidate: {type: Type}, type: Type, checkSubtype: boolean) {
346+
private typesMatch(candidate: {type: Type}, type: Type, checkSubtype: boolean) {
347347
const resolvedType = type.resolvedType();
348348
if (!resolvedType.isResolved()) {
349349
return (type instanceof CollectionType) === (candidate.type instanceof CollectionType) &&

src/tools/recipe2plan.ts

-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ async function generatePlans(resolutions: AsyncIterator<Recipe>): Promise<string
4040
return [''];
4141
}
4242

43-

0 commit comments

Comments
 (0)