http-moment
v1.1.0
Published
http(s).Agent that allows you to send multiple requests at exactly one moment
Downloads
9
Maintainers
Readme
http-moment
Multiple requests are processed by the server at exactly one specific moment
💿 Installation
npm i http-moment
❓ How it works
Send buffer except the last byte to the server
Ensure that all buffers are sent
Simultaneously send the last bytes of all requests
📖 Usage
import { http, https } from "http-moment";
const { http, https } = require("http-moment");
const agent = new https.Agent();
agent.cork(5);
for (let i = 0; i < 5; ++i)
request("https://example.com", { agent }, console.log);
agent.cork(2);
request("https://example.com", { agent }, console.log);
request.post("https://example.com/hello", { agent, body: "hi" }, console.log);
⏲ Http(s)Agent
Methods
cork
cork(count: Number = 0): Promise
count
- if>= 1
, would uncork agent aftercount
requests
/* Usage example */
agent.cork();
agent.cork(0);
agent.cork(5); /* auto uncork after 5 requests */
uncork
uncork(): Promise
It's better to provide specific count
instead of manual use this method
/* Usage example */
agent.cork();
request("https://example.com", { agent }, console.log);
request("https://example.com/hello", { agent }, console.log);
// agent.uncork() - you can't use uncork immediately
setTimeout(() => agent.uncork(), 3000);
📝 License
Released under MIT license