-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (24 loc) · 729 Bytes
/
index.js
File metadata and controls
30 lines (24 loc) · 729 Bytes
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
const request = require('request');
const maxCont = 6;
const getCommits = function(username, timeout, callback){
if(callback === undefined){
callback = timeout;
timeout = 4000;
}
const url = "http://github.com/" + username;
const opts = {
url: url,
timeout: timeout
};
request(opts, (err, response, body) => {
if (err) {
return callback(err);
}
const numStart = body.search(/[0-9]*(,)?[0-9]+ contributions/);
const num = body.substr(numStart, maxCont).split(" ")[0];
callback(undefined, num);
});
};
module.exports = function(username, timeout, callback){
return getCommits(username, timeout, callback);
};