import { Paginator } from "@aws-sdk/types" ; import { CognitoIdentity } from "../CognitoIdentity" ; import { CognitoIdentityClient } from "../CognitoIdentityClient" ; import { ListIdentityPoolsCommand , ListIdentityPoolsCommandInput , ListIdentityPoolsCommandOutput , } from "../commands/ListIdentityPoolsCommand" ; import { CognitoIdentityPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListIdentityPoolsCommandOutput > => { return await client . send ( new ListIdentityPoolsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListIdentityPoolsCommandOutput > => { return await client . listIdentityPools ( input , ... args ) ; } ; export async function * paginateListIdentityPools ( 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 CognitoIdentity ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof CognitoIdentityClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected CognitoIdentity | CognitoIdentityClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }