async function () {

        // while the array of all exchanges is not empty
        while (exchanges.length > 0) {

            // pop one exchange from the array
            const exchange = exchanges.pop ()

            // check if it has the necessary method implemented
            if (exchange.has['fetchTickers']) {

                // try to do "the work" and handle errors if any
                try {

                    // fetch the response for all tickers from the exchange
                    const tickers = await exchange.fetchTickers ()

                    // make a filename from exchange id
                    const filename = exchange.id + '.json'

                    // save the response to a file
                    fs.writeFileSync (filename, JSON.stringify ({ tickers }));

                    // print out a message on success
                    log.green (exchange.id, 'tickers saved to', filename)

                } catch (e) {

                    // in case of error - print it out and ignore it further
                    log.red (e.constructor.name, e.message)
                }

            } else {

                log.red (exchange.id, "has['fetchTickers'] = false");
            }
        }
    }
async function () {

        // while the array of all exchanges is not empty
        while (exchanges.length > 0) {

            // pop one exchange from the array
            const exchange = exchanges.pop ()

            // check if it has the necessary method implemented
            if (exchange.has['fetchTickers']) {

                // try to do "the work" and handle errors if any
                try {

                    // fetch the response for all tickers from the exchange
                    const tickers = await exchange.fetchTickers ()

                    // make a filename from exchange id
                    const filename = exchange.id + '.json'

                    // save the response to a file
                    fs.writeFileSync (filename, JSON.stringify ({ tickers }));

                    // print out a message on success
                    log.green (exchange.id, 'tickers saved to', filename)

                } catch (e) {

                    // in case of error - print it out and ignore it further
                    log.red (e.constructor.name, e.message)
                }

            } else {

                log.red (exchange.id, "has['fetchTickers'] = false");
            }
        }
    }
async function ( ) { // while the array of all exchanges is not empty while ( exchanges . length > 0 ) { // pop one exchange from the array const exchange = exchanges . pop ( ) // check if it has the necessary method implemented if ( exchange . has [ 'fetchTickers' ] ) { // try to do "the work" and handle errors if any try { // fetch the response for all tickers from the exchange const tickers = await exchange . fetchTickers ( ) // make a filename from exchange id const filename = exchange . id + '.json' // save the response to a file fs . writeFileSync ( filename , JSON . stringify ( { tickers } ) ) ; // print out a message on success log . green ( exchange . id , 'tickers saved to' , filename ) } catch ( e ) { // in case of error - print it out and ignore it further log . red ( e . constructor . name , e . message ) } } else { log . red ( exchange . id , "has['fetchTickers'] = false" ) ; } } }
the worker function for each "async thread"
the worker function for each async thread
fetch all the exchanges from the array