import { Paginator } from "@aws-sdk/types" ; import { CodeGuruProfiler } from "../CodeGuruProfiler" ; import { CodeGuruProfilerClient } from "../CodeGuruProfilerClient" ; import { ListProfilingGroupsCommand , ListProfilingGroupsCommandInput , ListProfilingGroupsCommandOutput , } from "../commands/ListProfilingGroupsCommand" ; import { CodeGuruProfilerPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListProfilingGroupsCommandOutput > => { return await client . send ( new ListProfilingGroupsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListProfilingGroupsCommandOutput > => { return await client . listProfilingGroups ( input , ... args ) ; } ; export async function * paginateListProfilingGroups ( 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 CodeGuruProfiler ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof CodeGuruProfilerClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected CodeGuruProfiler | CodeGuruProfilerClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }