request-worker

1.1.0 • Public • Published

Build Status NPM version

request-worker

Module that utilizes worker processes to perform HTTP requests. Useful if you need to make a large number of HTTP requests or the requests you're making will take a long time to get a response. request-worker uses the request module to perform the request; all the same options are supported.

Installation

This package is available on npm as:

npm install request-worker

Usage

A singleton is available if you want to share workers:

RequestWorker.getInstance({count: 16})
  .request({
    method : 'GET',
    url    : 'http://google.com/'
  })
  .then(function (results) {
    if (results.response.statusCode === 200) {
      var data = JSON.parse(results.body);
      // implementation...
    } else {
      // stuff...
    }
  })
  .fail(function (error) {
    // error handling...
  })
  .done();

You can also create your own instance:

var requestWorker = new RequestWorker({count: 16});
requestWorker
  .request(...)
  .then(...)
  .fail(...)
  .done();

License

MIT

Dependencies (3)

Dev Dependencies (6)

Package Sidebar

Install

npm i request-worker

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • scottbrady