import { IHubRequestOptions } from "@esri/hub-common" ; import { doesGroupExist } from "./does-group-exist" ; param { String } title param { IHubRequestOptions } hubRequestOptions param { Number } step export function getUniqueGroupTitle ( title , hubRequestOptions , step = 0 ) { let combinedName = title ; if ( step ) { combinedName = `${ title } ${ step }` ; } return doesGroupExist ( combinedName , hubRequestOptions ) . then ( result => { if ( result ) { step ++ ; return getUniqueGroupTitle ( title , hubRequestOptions , step ) ; } else { return combinedName ; } } ) . catch ( err => { throw Error ( `Error in team-utils::getUniqueGroupTitle ${ err }` ) ; } ) ; }