import { Paginator } from "@aws-sdk/types" ; import { CodeCommit } from "../CodeCommit" ; import { CodeCommitClient } from "../CodeCommitClient" ; import { GetDifferencesCommand , GetDifferencesCommandInput , GetDifferencesCommandOutput , } from "../commands/GetDifferencesCommand" ; import { CodeCommitPaginationConfiguration } from "./Interfaces" ; private const makePagedClientRequest = async ( client , input , ... args ) : Promise < GetDifferencesCommandOutput > => { return await client . send ( new GetDifferencesCommand ( input ) , ... args ) ; } ; private const makePagedRequest = async ( client , input , ... args ) : Promise < GetDifferencesCommandOutput > => { return await client . getDifferences ( input , ... args ) ; } ; export async function * paginateGetDifferences ( 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 CodeCommit ) { page = await makePagedRequest ( config . client , input , ... additionalArguments ) ; } else if ( config . client instanceof CodeCommitClient ) { page = await makePagedClientRequest ( config . client , input , ... additionalArguments ) ; } else { throw new Error ( "Invalid client, expected CodeCommit | CodeCommitClient" ) ; } yield page ; token = page . NextToken ; hasNext = ! ! token ; } return undefined ; }