@@ -20,12 +20,11 @@ A browser-compatible JSON-RPC client with multiple transports:
2020- PostMessageWindow
2121- PostMessageIframe
2222
23-
2423``` javascript
2524import { RequestManager , HTTPTransport , Client } from " @open-rpc/client-js" ;
2625const transport = new HTTPTransport (" http://localhost:8545" );
2726const client = new Client (new RequestManager ([transport]));
28- const result = await client .request ({method: " addition" , params: [2 , 2 ]});
27+ const result = await client .request ({ method: " addition" , params: [2 , 2 ] });
2928// => { jsonrpc: '2.0', id: 1, result: 4 }
3029```
3130
@@ -36,7 +35,11 @@ const result = await client.request({method: "addition", params: [2, 2]});
3635
3736``` javascript
3837import { EventEmitter } from " events" ;
39- import { RequestManager , EventEmitterTransport , Client } from " @open-rpc/client-js" ;
38+ import {
39+ RequestManager ,
40+ EventEmitterTransport ,
41+ Client ,
42+ } from " @open-rpc/client-js" ;
4043
4144const chan1 = " chan1" ;
4245const chan2 = " chan2" ;
@@ -57,7 +60,7 @@ emitter.on(chan1, (jsonrpcRequest) => {
5760});
5861
5962const main = async () => {
60- const result = await client .request ({method: " addition" , params: [2 , 2 ]});
63+ const result = await client .request ({ method: " addition" , params: [2 , 2 ] });
6164 console .log (result);
6265};
6366
@@ -68,7 +71,6 @@ main().then(() => {
6871
6972</details >
7073
71-
7274<details >
7375 <summary >HTTP</summary >
7476
@@ -80,7 +82,7 @@ const requestManager = new RequestManager([transport]);
8082const client = new Client (requestManager);
8183
8284const main = async () => {
83- const result = await client .request ({method: " addition" , params: [2 , 2 ]});
85+ const result = await client .request ({ method: " addition" , params: [2 , 2 ] });
8486 console .log (result);
8587};
8688
@@ -91,31 +93,43 @@ main().then(() => {
9193
9294</details >
9395
94-
9596<details >
9697 <summary >WebSocket</summary >
9798
9899``` javascript
99- import { RequestManager , Client , WebSocketTransport } from " @open-rpc/client-js" ;
100+ import {
101+ RequestManager ,
102+ Client ,
103+ WebSocketTransport ,
104+ } from " @open-rpc/client-js" ;
100105
101106const transport = new WebSocketTransport (" ws://localhost:3333" );
102107const requestManager = new RequestManager ([transport]);
103108const client = new Client (requestManager);
104109
105110const main = async () => {
106- const result = await client .request ({method: " addition" , params: [2 , 2 ]});
111+ const result = await client .request ({ method: " addition" , params: [2 , 2 ] });
107112 console .log (result);
108113};
109114
110115main ().then (() => {
111116 console .log (" DONE" );
112117 client .close ();
113118});
114-
115119```
116120
117121</details >
118122
123+ ### Building
124+
125+ ``` sh
126+ # Install bun
127+ curl -fsSL https://bun.sh/install | bash
128+
129+ # Build the repo
130+ bun install
131+ bun run build
132+ ```
119133
120134### Contributing
121135
0 commit comments