import { Paginator } from "@aws-sdk/types" ; import { ListOriginEndpointsCommand , ListOriginEndpointsCommandInput , ListOriginEndpointsCommandOutput , } from "../commands/ListOriginEndpointsCommand" ; import { MediaPackage } from "../MediaPackage" ; import { MediaPackageClient } from "../MediaPackageClient" ; import { MediaPackagePaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListOriginEndpointsCommandOutput > => { return await client . send ( new ListOriginEndpointsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListOriginEndpointsCommandOutput > => { return await client . listOriginEndpoints ( input , ... args ) ; } ; export async function * paginateListOriginEndpoints ( config , input , ... additionalArguments ) { let token = config . startingToken || undefined ; let hasNext = true ; let page ; while ( hasNext ) { input . NextToken = token ; input [ "MaxResults" ] = config . pageSize ; if ( config . client instanceof MediaPackage ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof MediaPackageClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected MediaPackage | MediaPackageClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }