-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample1.js
33 lines (29 loc) · 901 Bytes
/
sample1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
/*eslint-disable no-console */
var githubAPI = require('./github.api.js');
githubAPI.zen(function(err, response) {
if (!err) {
console.log('Chris says "' + response + '"');
}
});
// Print Highest Contributor to node repo.
githubAPI.contributors('nodejs', 'node', function(err, response) {
if (!err) {
var highest = response.reduce(function (acc, v) {
if (v.contributions > acc.contributions) {
acc.login = v.login;
acc.contributions = v.contributions;
}
return acc;
},
{contributions: -1}
);
githubAPI.user(highest.login, function(err, resp) {
if (!err) {
var name = resp.name ? resp.name : resp.login;
console.log('Highest contributions to \'nodejs/node\' made by ' + name + '.');
console.log('User ' + name + ' made ' + highest.contributions + ' contributions.');
}
});
}
});