Created
March 29, 2019 12:15
-
-
Save didasy/3e417991cc0b69148974fc3fdef687a5 to your computer and use it in GitHub Desktop.
Get Approximate LoC
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
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