Skip to content

Instantly share code, notes, and snippets.

@chinmay185
Created April 27, 2015 15:46
Show Gist options
  • Save chinmay185/30d6b7d70868f99d610b to your computer and use it in GitHub Desktop.
Save chinmay185/30d6b7d70868f99d610b to your computer and use it in GitHub Desktop.

Revisions

  1. chinmay185 created this gist Apr 27, 2015.
    12 changes: 12 additions & 0 deletions parallel-async.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    var Promise = require("bluebird");
    var productIds = ["productId1", "productId2", "productId3"];

    var getProductsFromDb = function(productId) {
    // returns a promise of product
    }

    var productPromises = productIds.map(getProductFromDb);

    Promise.all(productPromises).then(function(products) {
    // calculate total price here
    });