This package has been deprecated

Author message:

Will be updated

http2-sync
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

http2-sync

Build Status

💿 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 as createConnection param
/* Usage example */
http2.connect("https://example.com", {
  createConnection: sync.createConnection
});

Methods

cork

cork(countNumber = 0)
  • count - uncork after count frames with END_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(countNumber = 1);
  • count - wait for count frames with END_STREAM flag

Wait for frames with END_STREAM flag

/* Usage example */
await sync.wait(5);

📝 License

Released under MIT license

🦉 Alex Owl

Package Sidebar

Install

npm i http2-sync

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

16.3 kB

Total Files

9

Last publish

Collaborators

  • alexowl