UNPKG

@qso-soft/shared

Version:

Shared library for QSO-soft

21 lines 843 B
import { chunkArray } from '../utils'; export const startWithThreads = async ({ size, array, callback, logger }) => { const totalCount = array.length; let finishCount = 0; const chunkedArray = chunkArray(array, size); const allResults = []; for (const chunk of chunkedArray) { const promises = []; const currentIndex = finishCount + chunk.length; for (const chunkItem of chunk) { const promise = callback(chunkItem, logger, currentIndex); promises.push(promise); } const results = await Promise.allSettled(promises); finishCount = currentIndex; logger.success(`Total wallets: [${finishCount}/${totalCount}]`, { action: 'startWithThreads' }); allResults.push(results); } return allResults; }; //# sourceMappingURL=threads.js.map