Class: Throttle

Throttle(options)

## Throttle The throttle object.

Constructor

new Throttle(options)

Parameters:
Name Type Description
options object key value options
Source:

Methods

_isRateBound() → {Boolean}

## _isRateBound returns true if throttle is bound by rate
Source:
Returns:
Type
Boolean

_options(options)

## _options updates options on instance
Parameters:
Name Type Description
options Object key value object
Source:
Returns:
null

cycle(request)

## cycle an iterator of sorts. Should be called when - something added to throttle (check if it can be sent immediately) - `ratePer` ms have elapsed since nth last call where n is `rate` (may have available rate) - some request has ended (may have available concurrency)
Parameters:
Name Type Description
request Request the superagent request
Source:
Returns:
null

next() → {Boolean}

## next checks whether instance has available capacity and calls throttle.send()
Source:
Returns:
Type
Boolean

options(options, valueopt)

## options thin wrapper for _options * calls `this.cycle()` * adds alternate syntax alternate syntax: throttle.options('active', true) throttle.options({active: true})
Parameters:
Name Type Attributes Description
options Object either key value object or keyname
value Mixed <optional>
value for key
Source:
Returns:
null

plugin(serial)

## plugin `superagent` `use` function should refer to this plugin method a la `.use(throttle.plugin())` mask the original `.end` and store the callback passed in
Parameters:
Name Type Description
serial string any string is ok, it's just a namespace
Source:
Returns:
null

send(request)

## send sends a queued request.
Parameters:
Name Type Description
request Request superagent request
Source:
Returns:
null

serial(request, state)

## serial updates throttle.\_serials and throttle.\_isRateBound serial subthrottles allow some requests to be serialised, whilst maintaining their place in the queue. The _serials structure keeps track of what serial queues are waiting for a response. ``` throttle._serials = { 'example.com/end/point': true, 'example.com/another': false } ```
Parameters:
Name Type Description
request Request superagent request
state Boolean new state for serial
Source: