jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.5k stars 132 forks source link

Revert: Fix remainingRequests example in README #65

Closed chrisvxd closed 3 years ago

chrisvxd commented 4 years ago

Thanks for awesome lib 🙏

This PR reverts fix 544a9007539d5af2323d38f05996c86edc8a87c4 that seems to have incorrectly updated the fire immediately example in the README.

To test, I used a very low rate limit of 2 / hour and noted the remainingRequests values:

  1. First call, remainingRequests = 1
  2. Second call, remainingRequests = 0.0017561111111110694
  3. Third call, remainingRequests = -1 (as expected according to docs)

What was expected to happen

Example should be failing on third call, with 2 valid executions.

What actually happened

Example failed on second call, with 1 valid execution, i.e. 1 short of the target rate limit.