import { Paginator } from "@aws-sdk/types" ; import { DescribeCacheEngineVersionsCommand , DescribeCacheEngineVersionsCommandInput , DescribeCacheEngineVersionsCommandOutput , } from "../commands/DescribeCacheEngineVersionsCommand" ; import { ElastiCache } from "../ElastiCache" ; import { ElastiCacheClient } from "../ElastiCacheClient" ; import { ElastiCachePaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < DescribeCacheEngineVersionsCommandOutput > => { return await client . send ( new DescribeCacheEngineVersionsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < DescribeCacheEngineVersionsCommandOutput > => { return await client . describeCacheEngineVersions ( input , ... args ) ; } ; export async function * paginateDescribeCacheEngineVersions ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . Marker = token ; input [ "MaxRecords" ] = config . pageSize ; if ( config . client instanceof ElastiCache ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof ElastiCacheClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected ElastiCache | ElastiCacheClient" ) ; } yield page ; token = page . Marker ; hasNext = ! ! token ; } return undefined ; }