export const getAll = async < Entity > ( getPageEntities ) => { let nextMarker = undefined ; let page = 0 ; const entities = [ ] ; while ( true ) { page ++ ; const entitiesResponse = await getPageEntities ( nextMarker , page ) ; entities . push ( ... entitiesResponse . items ) ; if ( entitiesResponse . nextMarker ) { nextMarker = entitiesResponse . nextMarker ; } else { return entities ; } } } ;