Created
September 15, 2014 11:58
-
-
Save doubleshow/95e3f43345de9b041183 to your computer and use it in GitHub Desktop.
Get all forks from the repos of challenges 1, 2, and 3
This file contains 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 characters
var GitHubApi = require("github"); | |
var async = require("async"); | |
var github = new GitHubApi({ | |
// required | |
version: "3.0.0", | |
// optional | |
timeout: 5000 | |
}); | |
function getForksForChallengeWeek(i, callback) { | |
github.repos.getForks({ | |
user: "CSCI-4830-002-2014", | |
repo: "challenge-week-" + i | |
}, callback); | |
}; | |
// [ [a,a,a], [b,b,b], ... ] -> [a,a,a,b,b,b, ... ] | |
function flatten_slow(input){ | |
return input.reduce(function(a, b) { | |
return a.concat(b); | |
}, []); | |
} | |
async.map([1,2,3], getForksForChallengeWeek, function(err, results){ | |
flattened = flatten_slow(results); | |
console.log(JSON.stringify(flattened, undefined, 4)); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment