import { Paginator } from "@aws-sdk/types" ; import { ListWorkersWithQualificationTypeCommand , ListWorkersWithQualificationTypeCommandInput , ListWorkersWithQualificationTypeCommandOutput , } from "../commands/ListWorkersWithQualificationTypeCommand" ; import { MTurk } from "../MTurk" ; import { MTurkClient } from "../MTurkClient" ; import { MTurkPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListWorkersWithQualificationTypeCommandOutput > => { return await client . send ( new ListWorkersWithQualificationTypeCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListWorkersWithQualificationTypeCommandOutput > => { return await client . listWorkersWithQualificationType ( input , ... args ) ; } ; export async function * paginateListWorkersWithQualificationType ( 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 MTurk ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof MTurkClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected MTurk | MTurkClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }