here in loop I'm doing some db operations. Can I use multi-threading concept to call async function "addInputs" so that it would execute faster?

`for(const temp of {
if (temp.txid) {
  let results =  await addInputs(temp.txid,temp.vout)
         "value": results[0],
         "address": results[1]

1 Answers

Ferrybig On Best Solutions

While JavaScript does not have multithreading, a trick you can use in this situation is to fill an array with promises, and then await them all at once:

const array = []
for(const id of ids) {
    array.push(addInputs (id));
const result =  await Promise.all(array);