Last active
August 29, 2015 14:19
-
-
Save chinmay185/035a07cc0234a75ece03 to your computer and use it in GitHub Desktop.
Revisions
-
chinmay185 revised this gist
Apr 28, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var request = function(url) { }; var saveResponse = function(response) { // save response to file/db (returns a promise) }; apiUrls .reduce(function (accumulatedPromise, url) { -
chinmay185 revised this gist
Apr 28, 2015 . 1 changed file with 11 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,12 +8,14 @@ var saveResponse = function(response) { // save response to file/db (returns a promise) } apiUrls .reduce(function (accumulatedPromise, url) { return accumulatedPromise .then(function () { return request(url); }) .then(saveResponse); }, Promise.resolve()) .then(function () { console.log("all done."); }); -
chinmay185 revised this gist
Apr 28, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,4 +14,6 @@ apiUrls.reduce(function(accumulatedPromise, url) { return request(url); }) .then(saveResponse); }, Promise.resolve()).then(function(){ console.log("all done."); }); -
chinmay185 revised this gist
Apr 24, 2015 . 1 changed file with 9 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,17 @@ var Promise = require("bluebird"); var apiUrls = ["url1", "url2", "url3"]; var request = function(url) { // request the rate limited api (returns a promise) }; var saveResponse = function(response) { // save response to file/db (returns a promise) } apiUrls.reduce(function(accumulatedPromise, url) { return accumulatedPromise .then(function() { return request(url); }) .then(saveResponse); }, Promise.resolve()); -
chinmay185 revised this gist
Apr 24, 2015 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,13 +2,15 @@ var Promise = require("bluebird"); var usernames = ["tom", "harry", "jack"]; var getUser = function(username) { return Promise.delay(1000).then(function() { return username + " user"; }); }; usernames.reduce(function(accumulatedPromise, username) { return accumulatedPromise .then(function() { return getUser(username); }) .then(console.log); }, Promise.resolve()); -
chinmay185 created this gist
Apr 24, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ var Promise = require("bluebird"); var usernames = ["tom", "harry", "jack"]; var getUser = function(username) { return Promise.delay(1000).then(function() { return username + " user"; }); }; usernames.reduce(function(accumulatedPromise, username) { return accumulatedPromise.then(function() { return getUser(username); }).then(console.log); }, Promise.resolve());