Class: SlidingWindow

SlidingWindow()

new SlidingWindow()

Create a sliding window counter e.g:

new SlidingWindow({
  window: 1000,
  limit: 100
})

creates a sliding window which allows 100 requests per second

Properties:
Name Type Description
window Number

window period in milliseconds

limit Number

max requests allowed

timeout Timeout

sliding window timeout

current Number

current window counter

previous Number

previous window counter

timestamp Number

current window start time in milliseconds

Source: