npm.io
0.4.1 • Published yesterday

@polkadot-api/json-rpc-provider-proxy

Licence
MIT
Version
0.4.1
Deps
0
Size
30 kB
Vulns
0
Weekly
0
Stars
155

@polkadot-api/json-rpc-provider-proxy

This package exports getSyncProvider, a function to create JsonRpcProviders that will act as if the connection happen synchronously.

export type AsyncJsonRpcProvider = (
  onMessage: (message: string) => void,
  onHalt: () => void,
) => JsonRpcConnection

function getSyncProvider(
  input: () => Promise<AsyncJsonRpcProvider>,
): JsonRpcProvider

The returned provider will buffer up every message until it can get the JsonRpcConnection, at which point it will send every message buffered.