5.1.3 ā€¢ Published 12 months ago

rock-req v5.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

npm ci javascript style guide

šŸ”„ Why?

In most existing libraries (2023):

  • Managing reliable retries is difficult, tricky with streams and not battle-tested
  • Using multiple forward proxies has several benefits like higher availability and increased bandwidth but Intercepting retries to use another Egress controller between two requests is not possible.
  • Many request libraries are heavy: node-fetch, superagent, needle, got, axios, request
  • Lightweight alternatives are not as light as they claim due to dependencies (simple-get, tiny-req, puny-req, phin, ...)

āš”ļø Rock-req solves these problems with only 150 lines of code and zero dependencies

It also supports many features:

  • Follows redirects
  • Handles gzip/deflate/brotli responses
  • Modify defaults
  • Extend and create new instances
  • Automatically destroy input/output stream on error and premature close event
  • Advanced retries
  • URL Rewrite
  • Ultra-fast (> 20k req/s)
  • Keep Alive by default (3000ms)
  • Composable
  • Timeouts
  • HTTPS / HTTP
  • Composes well with npm packages for features like cookies, proxies, form data, & OAuth
  • Keep 98% of the simple-get API (fork source)

When the callback is called, the request is 100% finished, even with streams.

šŸš€ Benchmark Rock-req vs got, axios, node-fetch, phin, simple-get, superagent, ...

Stop using "slow by-default" and "false-light" HTTP request libraries!

LibraryNodeJS 16NodeJS 18NodeJS 20*Size deps inc.
rock-req šŸ™‹ā€ā™‚ļø22816 req/s21797 req/s21964 req/s144 LOC
simple-get2937 req/s3260 req/s21258 req/s317 LOC
axios5090 req/s4910 req/s3196 req/s13983 LOC
got2163 req/s1762 req/s9961 req/s9227 LOC
fetch2101 req/s2102 req/s2020 req/s13334 LOC
request2249 req/s1869 req/s15815 req/s46572 LOC
superagent2776 req/s2100 req/s2895 req/s16109 LOC
phin3178 req/s1164 req/s21299 req/s331 LOC
undici*24095 req/s24378 req/s24191 req/s16225 LOC

NodeJS 20 activates HTTP keep-alive by default, like rock-req

undici is a low-level API, faster alternative to the native NodeJS http module. It is the glass ceiling limit for NodeJS.

rock-req uses only the native NodeJS http module and provides many high-level features, a lot more than phin and simple-get with fewer lines of code.

Tested on Macbook Pro M1 Max

Install

  npm install rock-req

Documentation

The full documentation is here to reduce Node package file size.

Supporters

This packaged in maintained by Carbone:

Thank you Feross Aboukhadijeh, creator of simple-get