Untitled
unknown
plain_text
a year ago
969 B
13
Indexable
/** * Makes parallel HTTP requests to the given array of URLs, with a constraint on the number * of simultaneous requests allowed. Once all requests are completed, calls the provided * callback function with an array of text responses in the same order as the input URLs. * * @param {string[]} urls - An array of URLs to make HTTP requests to. * @param {number} limit - The maximum number of simultaneous HTTP requests allowed. * @param {function(string[]): void} callback - The callback function to be called with an * array of text responses once all requests are completed. */ function parallelHttpRequests(urls, limit, callback) { const reqs = []; let j = 0; urls.forEach((el, i) => { if (reqs[j].length > limit) { j += 1; } reqs[j] = reqs[j].push(el); }); const doneRequests = []; Promise.race(subArr.map((arg) => fetch(arg).then((req) => req.text()))) reqs.map((subArr) => { return ; }) }
Editor is loading...
Leave a Comment