title: How can I decide on what method to include and what to reject in an async.parallel array of Async methods
body: <p>We're using the Async library's parallel() method to make parallel asynchronous API calls. So the code somewhat looks like this :</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>async.parallel({
      a: (callback)=&gt; aHelper(searchValue, callback),
      b: (callback) =&gt; bHelper(searchValue, callback),
      c: (callback) =&gt; cHelper(searchValue, null, callback)
  },
  
  function (error, result){
      console.log("Error", error)
      console.log("Results", result)
  })</code></pre>
  </div>
  </div>
  </p>
  <p>Now, we want to add a case here. We'll be adding a check for every value being passed into the parallel method. Let's say if I only want response of &quot;a&quot; and &quot;c&quot; (as per code), how do I avoid calling &quot;b&quot; in this case?
  We tried a different approach for this.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>ParallelAsync.parallel({
      a: (callback)=&gt; {true ? aHelper(searchValue, callback) : callback(true, null)},
      b: (callback)=&gt; {false ? bHelper(searchValue, callback) : callback(true, null)},
      c: (callback) =&gt; {true ? cHelper(searchValue, callback): callback(true, null)}
  },
  
  function (error, result){
      console.log("Error", error)
      console.log("Results", result)
  })</code></pre>
  </div>
  </div>
  </p>
  <p>We tried this, but as per the documentation on <strong>async's parallel</strong> method, if any of our method is synchronous (in this case, it's callback(true, null) ) the flow will be executed synchronously. I also tried making callback(true,null) as a promise response, still the code is executed in a synchronous manner.</p>
  <p>Is there any solutions to this issue?</p>
  <p>Ref</p>
  <ol>
  <li>async docs --&gt; <a href="https://caolan.github.io/async/v3/docs.html#parallel" rel="nofollow noreferrer">https://caolan.github.io/async/v3/docs.html#parallel</a></li>
  </ol>