Skip to content

Instantly share code, notes, and snippets.

@doubleshow
Created September 15, 2014 11:58
Show Gist options
  • Save doubleshow/95e3f43345de9b041183 to your computer and use it in GitHub Desktop.
Save doubleshow/95e3f43345de9b041183 to your computer and use it in GitHub Desktop.
Get all forks from the repos of challenges 1, 2, and 3
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