Skip to content

Instantly share code, notes, and snippets.

@futurist
Created June 28, 2016 06:48
Show Gist options
  • Save futurist/a40359b2ae1dfae7c4e4037b251303d7 to your computer and use it in GitHub Desktop.
Save futurist/a40359b2ae1dfae7c4e4037b251303d7 to your computer and use it in GitHub Desktop.
get total count lines for repo during 1 week
//replace jquery/jquery with the repo you're interested in
fetch('https://api.github.com/repos/jquery/jquery/stats/contributors')
.then(response => response.json())
.then(contributors => contributors
.map(contributor => contributor.weeks
.reduce((lineCount, week) => lineCount + week.a - week.d, 0)))
.then(lineCounts => lineCounts.reduce((lineTotal, lineCount) => lineTotal + lineCount))
.then(lines => window.alert(lines));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment