fix(sonar): move default out of runPool parameter list (javascript:S1788)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e81ebbc45b
commit
8f856c8f8b
@ -358,9 +358,9 @@ function ttvcIsLowMemoryDevice() {
|
|||||||
window.ttvcIsLowMemoryDevice = ttvcIsLowMemoryDevice;
|
window.ttvcIsLowMemoryDevice = ttvcIsLowMemoryDevice;
|
||||||
// Run an async worker over items with bounded concurrency (default 4). `onProgress(done,total)`
|
// Run an async worker over items with bounded concurrency (default 4). `onProgress(done,total)`
|
||||||
// fires after each item. Replaces slow serial `for…await` loops over network calls.
|
// fires after each item. Replaces slow serial `for…await` loops over network calls.
|
||||||
async function runPool(items, worker, concurrency = 4, onProgress) {
|
async function runPool(items, worker, concurrency, onProgress) {
|
||||||
const arr = [...items]; let i = 0, done = 0; const total = arr.length;
|
const arr = [...items]; let i = 0, done = 0; const total = arr.length;
|
||||||
const requested = Math.max(1, Number(concurrency) || 1);
|
const requested = Math.max(1, Number(concurrency ?? 4) || 1);
|
||||||
const effectiveConcurrency = ttvcIsLowMemoryDevice() ? Math.min(2, requested) : requested;
|
const effectiveConcurrency = ttvcIsLowMemoryDevice() ? Math.min(2, requested) : requested;
|
||||||
async function run() {
|
async function run() {
|
||||||
while (i < arr.length) {
|
while (i < arr.length) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user