import { S3Metadata } from '../s3' ; import { FindBehavior } from './behaviors/FindBehavior' ; /**
 *
 */ export class ReferenceList { private findBehavior : FindBehavior < any > ; private prefix : string ; private continuationToken ? : string ; private hasMore : boolean ; private pageSize : number ; private totalCount : number ; private references ? : S3Metadata [ ] ; constructor ( findBehavior , prefix , continuationToken ? , hasMore ? , pageSize ? , totalCount ? ) { this . findBehavior = findBehavior ; this . continuationToken = continuationToken ; this . prefix = prefix ; this . hasMore = hasMore || false ; this . pageSize = pageSize || 100 ; this . totalCount = totalCount || 0 ; } public async * iterator ( ) { let hasMoreNow = ! ! this . references && this . references . length !== 0 ; while ( hasMoreNow ) { if ( this . references ) { for ( const s3Metadata of this . references ) { yield s3Metadata ; } } if ( this . hasMore ) { const referenceList = await this . findBehavior . find ( this . prefix , this . pageSize , this . continuationToken ) ; this . hasMore = referenceList . hasMore ; this . continuationToken = referenceList . continuationToken ; } else { hasMoreNow = false ; } } } public getConinuationToken ( ) { return this . continuationToken ; } public getHasMore ( ) { return this . hasMore ; } public getPageSize ( ) { return this . pageSize ; } public getTotalCount ( ) { return this . totalCount ; } public getReferences ( ) { return this . references || [ ] ; } public addReference ( reference ) { if ( ! this . references ) this . references = [ ] ; this . references . push ( reference ) ; } }