README
http2-sync
💿 Installation
npm i http2-sync
📖 Usage
import SyncClient from "http2-sync";
const SyncClient = require("http2-sync");
import http2 from "http2";
const sync = new SyncClient();
const client = http2.connect("https://example.com", {
createConnection: sync.createConnection
});
sync.cork(5);
for (let i = 0; i < 5; ++i) {
const stream = client.request({ ":path": "/" });
stream.on('data' console.log)
}
🌚 SyncClient
Properties
createConnection
createConnection: Function;
- Need to be passed to
http2.connect
ascreateConnection
param
/* Usage example */
http2.connect("https://example.com", {
createConnection: sync.createConnection
});
Methods
cork
cork(count: Number = 0)
count
- uncork aftercount
frames withEND_STREAM
flag received
Buffer requests instead of writing they to socket
/* Usage example */
sync.cork();
sync.cork(5);
uncork
uncork();
Write all saved buffer in one tcp packet
/* Usage example */
sync.uncork();
wait
wait(count: Number = 1);
count
- wait forcount
frames withEND_STREAM
flag
Wait for frames with END_STREAM
flag
/* Usage example */
await sync.wait(5);
📝 License
Released under MIT license