Skip to content

Commit a8cb40b

Browse files
committed
Removed redundant anonymous functions
1 parent 44875e4 commit a8cb40b

File tree

1 file changed

+10
-38
lines changed

1 file changed

+10
-38
lines changed

src/github.js

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@
250250

251251
this.userStarred = function (username, cb) {
252252
// Github does not always honor the 1000 limit so we want to iterate over the data set.
253-
_requestAllPages('/users/' + username + '/starred?type=all&per_page=100', function (err, res) {
254-
cb(err, res);
255-
});
253+
_requestAllPages('/users/' + username + '/starred?type=all&per_page=100', cb);
256254
};
257255

258256
// List a user's gists
@@ -360,9 +358,7 @@
360358
// repo.deleteRef('tags/v1.0')
361359

362360
this.deleteRef = function (ref, cb) {
363-
_request('DELETE', repoPath + '/git/refs/' + ref, options, function (err, res, xhr) {
364-
cb(err, res, xhr);
365-
});
361+
_request('DELETE', repoPath + '/git/refs/' + ref, options, cb);
366362
};
367363

368364
// Create a repo
@@ -383,13 +379,7 @@
383379
// -------
384380

385381
this.listTags = function (cb) {
386-
_request('GET', repoPath + '/tags', null, function (err, tags, xhr) {
387-
if (err) {
388-
return cb(err);
389-
}
390-
391-
cb(null, tags, xhr);
392-
});
382+
_request('GET', repoPath + '/tags', null, cb);
393383
};
394384

395385
// List all pull requests of a respository
@@ -437,30 +427,21 @@
437427
url += '?' + params.join('&');
438428
}
439429

440-
_request('GET', url, null, function (err, pulls, xhr) {
441-
if (err) return cb(err);
442-
cb(null, pulls, xhr);
443-
});
430+
_request('GET', url, null, cb);
444431
};
445432

446433
// Gets details for a specific pull request
447434
// -------
448435

449436
this.getPull = function (number, cb) {
450-
_request('GET', repoPath + '/pulls/' + number, null, function (err, pull, xhr) {
451-
if (err) return cb(err);
452-
cb(null, pull, xhr);
453-
});
437+
_request('GET', repoPath + '/pulls/' + number, null, cb);
454438
};
455439

456440
// Retrieve the changes made between base and head
457441
// -------
458442

459443
this.compare = function (base, head, cb) {
460-
_request('GET', repoPath + '/compare/' + base + '...' + head, null, function (err, diff, xhr) {
461-
if (err) return cb(err);
462-
cb(null, diff, xhr);
463-
});
444+
_request('GET', repoPath + '/compare/' + base + '...' + head, null, cb);
464445
};
465446

466447
// List all branches of a repository
@@ -486,10 +467,7 @@
486467
// -------
487468

488469
this.getCommit = function (branch, sha, cb) {
489-
_request('GET', repoPath + '/git/commits/' + sha, null, function (err, commit, xhr) {
490-
if (err) return cb(err);
491-
cb(null, commit, xhr);
492-
});
470+
_request('GET', repoPath + '/git/commits/' + sha, null, cb);
493471
};
494472

495473
// For a given file path, get the corresponding sha (blob for files, tree for dirs)
@@ -613,9 +591,7 @@
613591
this.updateHead = function (head, commit, cb) {
614592
_request('PATCH', repoPath + '/git/refs/heads/' + head, {
615593
sha: commit
616-
}, function (err) {
617-
cb(err);
618-
});
594+
}, cb);
619595
};
620596

621597
// Show repository information
@@ -779,9 +755,7 @@
779755

780756
that.postTree(tree, function (err, rootTree) {
781757
that.commit(latestCommit, rootTree, 'Deleted ' + path, function (err, commit) {
782-
that.updateHead(branch, commit, function (err) {
783-
cb(err);
784-
});
758+
that.updateHead(branch, commit, cb);
785759
});
786760
});
787761
});
@@ -967,9 +941,7 @@
967941
this.comment = function (issue, comment, cb) {
968942
_request('POST', issue.comments_url, {
969943
body: comment
970-
}, function (err, res) {
971-
cb(err, res);
972-
});
944+
}, cb);
973945
};
974946
};
975947

0 commit comments

Comments
 (0)