@lodestar/api
Version:
A Typescript REST client for the Ethereum Consensus API
8 lines (7 loc) • 305 B
text/typescript
// This function switches between the native web implementation and a nodejs implemnetation
export async function getEventSource(): Promise<typeof EventSource> {
if (globalThis.EventSource) {
return EventSource;
}
return (await import("eventsource")).default as unknown as typeof EventSource;
}