import{ISource}from"./source.ts"; /** * A SourceFileBag holds ISource */exportclassSourceFileBagextendsSet<ISource>{privatestaticcreate(items:ISource[]):SourceFileBag{const fileBag =newSourceFileBag();if(items){for(const item of items){ fileBag.add(item);}}return fileBag;} /** * Merge this SourceFileBag with another * @param other * @returns A new SourceFileBag with the merged result */merge(other:SourceFileBag){const sources =newSourceFileBag(); for(const source ofthis.values()){ sources.add(source);} for(const source of other.values()){ sources.add(source);} return sources;} find(predicate:(file:ISource)=>boolean){for(const source ofthis.values()){if(predicate(source)){return source;}}} filter(predicate:(file:ISource)=>boolean){const items:ISource[]=[];for(const source ofthis.values()){if(predicate(source)){ items.push(source);}} returnSourceFileBag.create(items);} toArray(){returnArray.from(this.values());}}