Skip to content

Instantly share code, notes, and snippets.

@didasy
Created March 29, 2019 12:15
Show Gist options
  • Save didasy/3e417991cc0b69148974fc3fdef687a5 to your computer and use it in GitHub Desktop.
Save didasy/3e417991cc0b69148974fc3fdef687a5 to your computer and use it in GitHub Desktop.
Get Approximate LoC
let headers = new Headers();
//headers.append('Content-Type', 'text/json');
headers.append('Authorization', 'Basic ' + btoa('username' + ":" + 'token'))
fetch('https://api.github.com/repos/username/reponame/stats/contributors', { method:'GET', headers: headers })
.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