( async() => { const items = 'abcdefghijklmnopqrstuvwxyz'.split(''); const concurrency = 10; async function process() { return new Promise( r => setTimeout( r, Math.random() * 1000 ) ); } async function report({ item, processed, total, done }){ if ( done ) { return console.log( 'Processing complete (%d items)', total ); } console.log( 'Processed %s (%d of %d)', item, processed, total ); } await queue({ items, concurrency, process, report }); console.log('Done'); })();