import { Paginator } from "@aws-sdk/types" ; import { ListContentsCommand , ListContentsCommandInput , ListContentsCommandOutput , } from "../commands/ListContentsCommand" ; import { Wisdom } from "../Wisdom" ; import { WisdomClient } from "../WisdomClient" ; import { WisdomPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < ListContentsCommandOutput > => { return await client . send ( new ListContentsCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < ListContentsCommandOutput > => { return await client . listContents ( input , ... args ) ; } ; export async function * paginateListContents ( 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 Wisdom ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof WisdomClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected Wisdom | WisdomClient" ) ; } yield page ; token = page . nextToken ; hasNext = ! ! token ; } return undefined ; }