1.0.0 • Published 7 years ago
http2-sync v1.0.0
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.connectascreateConnectionparam
/* Usage example */
http2.connect("https://example.com", {
createConnection: sync.createConnection
});Methods
cork
cork(count: Number = 0)count- uncork aftercountframes withEND_STREAMflag 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 forcountframes withEND_STREAMflag
Wait for frames with END_STREAM flag
/* Usage example */
await sync.wait(5);📝 License
Released under MIT license
🦉 Alex Owl
1.0.0
7 years ago