1.0.4 • Published 8 months ago

@jswork/concurrency-request v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

concurrency-request

An efficiently handles asynchronous data requests with customizable concurrency limit.

version license size download

installation

npm install @jswork/concurrency-request

usage

import ConcurrencyRequest from '@jswork/concurrency-request';

const urls = [];
for (let i = 1; i <= 10; i++) {
  urls.push(`https://jsonplaceholder.typicode.com/todos/${i}`);
}

function request(opts, callback) {
  fetch(opts.data)
    .then((r) => r.json())
    .then((data) => {
      callback({ success: true, data });
    })
    .catch((data) => {
      callback({ success: false, data });
    });
}

ConcurrencyRequest.start(urls, { max: 3, request }).then((res) => {
  console.log(res);
});

license

Code released under the MIT license.

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago