import { Paginator } from "@aws-sdk/types" ; import { ListProjectsCommand , ListProjectsCommandInput , ListProjectsCommandOutput , } from "../commands/ListProjectsCommand" ; import { IoT1ClickProjects } from "../IoT1ClickProjects" ; import { IoT1ClickProjectsClient } from "../IoT1ClickProjectsClient" ; import { IoT1ClickProjectsPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListProjectsCommandOutput > => { return await client . send ( new ListProjectsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListProjectsCommandOutput > => { return await client . listProjects ( input , ... args ) ; } ; export async function * paginateListProjects ( 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 IoT1ClickProjects ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof IoT1ClickProjectsClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected IoT1ClickProjects | IoT1ClickProjectsClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }