0.0.2 • Published 11 years ago

request-queue v0.0.2

Weekly downloads
4
License
-
Repository
github
Last release
11 years ago

#request-queue

put HTTP requests in a tasks-queue to execute them sequentially and not too often

#Getting Started Install the module with:

npm install request-queue

#Documentation

##RequestQueue

The class for the HTTP request queue. Inherits from TasksQueue. It hides the methods TasksQueue.prototype.pushTask and TasksQueue.prototype.unshiftTask. Use RequestQueue.prototype.pushRequest() and RequestQueue.prototype.unshiftRequest() methods instead.

RequestQueue depends on the following modules:

###setRequestDefaults(requestOptions)

Set default options for the request. See request.defaults().

###addScripts(paths)

Add scripts paths or URLs that are passed to jsdom.env as scripts option.

###getScripts()

Return an array of paths added with addScripts(paths).

###pushRequest(requestType,requestOptions) ###unshiftRequest(requestType,requestOptions) ###addRequest(where,requestType,requestOptions)

Insert a request to the queue.

pushRequest(t,o) is equivalent to addRequesr('tail',t,o). unshiftRequest(t,o) is equivalent to addRequesr('head',t,o).

If where equals to 'head', addRequest prepends the request to the head of the queue, otherwise it appends it to the tail.

requestType is a string, used to distinguish the different types of requests. Don't use strings that start with double colon ("::type").

requestOptions are passed to request(options,callback) that does the actual http request.

###requestType event

The requestType event is emitted when the response is retrieved and the DOM is built. Listeners are called with three arguments:

#Examples

See examples directory

#Contributing In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

#Release History

  • April 1, 2013. V. 0.0.1. Basic functionality

License Copyright (c) 2013 Andrei V. Toutoukine Licensed under the MIT license.