1.0.0 ⢠Published 5 years ago
@joemccann/flood v1.0.0
Flood
š Flood a network with requests in batches with retries.
Usage
npm i -S @joemccann/floodconst flood = require('@joemccann/flood')
const data = {
  batchSize: 50, // The number of simultaneous requests...
  done: (data) => {
    // write to file or console.dir(data)
    // Data is an array of objects of type {data: [...], url: 'http://...'}
  },
  errorHandler: (e, results) => { 
    console.error(e) 
    // do something with the results maybe?
  },
  sleepTime: 100, // sleep in between batches, not each request; in milliseconds
  url: `http://localhost:8080/api/foo?id={iteration}`, // {iteration} is REQUIRED
  values: ['a','b','c'] // the value to update on the query string
}
try{
  const { data, err } = await flood(data)
  console.dir(data) // data is the same data passed into done()
} catch(e) {
  console.error(e)
}NOTE: The retries will go on forever so be wise about how you handle the errors.
Tests
npm i -D
npm testAuthors
LICENSE
MIT
1.0.0
5 years ago