Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

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

install

npm i request-worker

Downloadsweekly downloads

5

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability