-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
34 lines (29 loc) · 798 Bytes
/
index.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
34
'use strict';
var GitHub = require('github-base');
var format = require('format-people');
module.exports = function contributors(repo, options, cb) {
if (typeof options === 'function') {
cb = options;
options = {};
}
if (typeof cb !== 'function') {
throw new TypeError('expected callback to be a function.');
}
if (typeof repo !== 'string') {
cb(new TypeError('expected repo to be a string.'));
return;
}
var method = options && options.format || 'noop';
var github = new GitHub(options);
github.paged(`/repos/:${repo}/contributors`, function(err, data) {
if (err) {
if (/CreateListFromArrayLike/.test(err.message)) {
cb(null, []);
return;
}
cb(err);
return;
}
cb(null, format(data, options));
});
};