import { Executor , RequestCoordinator } from "@ganache/utils" ; import { DefaultFlavor , FlavorName } from "@ganache/flavors" ; import { GetConnector , Options as ProviderOptions } from "@ganache/flavors" ; const initialize = < T extends FlavorName = typeof DefaultFlavor > ( options = { flavor : DefaultFlavor , chain : { asyncRequestProcessing : true } } as ProviderOptions < T > ) => { const flavor = ( options . flavor || DefaultFlavor ) as T ; let asyncRequestProcessing ; if ( "chain" in options && "asyncRequestProcessing" in options [ "chain" ] ) { asyncRequestProcessing = options [ "chain" ] . asyncRequestProcessing ; } else if ( "asyncRequestProcessing" in options ) { asyncRequestProcessing = options [ "asyncRequestProcessing" ] ; } else { asyncRequestProcessing = true ; } const requestCoordinator = new RequestCoordinator ( asyncRequestProcessing ? 0 : 1 ) ; const executor = new Executor ( requestCoordinator ) ; const connector = GetConnector ( flavor , options , executor ) ; const connectPromise = connector . connect ? connector . connect ( ) : ( ( connector as any ) . initialize ( ) as Promise < void > ) ; return { connector , promise : connectPromise . then ( requestCoordinator . resume ) } ; } ; /**
 * Loads the connector specified by the given `flavor`
 */ export default { initialize } ;