Skip to content

Commit

Permalink
avoid function recreation per call
Browse files Browse the repository at this point in the history
  • Loading branch information
shinnn committed Oct 25, 2016
1 parent 23673c9 commit 5c065af
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
const arrFilter = require('arr-filter');
const ghUserEvents = require('gh-user-events');

function filterPushes(event) {
return event.type === 'PushEvent';
}

function excludeNonPushEvents(events) {
return Promise.resolve(arrFilter(events, filterPushes));
}

module.exports = function ghUserPushes(user, options) {
options = options || {};
options.headers = Object.assign({
'user-agent': 'https://github.com/shinnn/github-user-push-events'
}, options.headers);

return ghUserEvents(user, options).then(function excludeNonPushEvents(events) {
return Promise.resolve(arrFilter(events, function filterPushes(event) {
return event.type === 'PushEvent';
}));
});
return ghUserEvents(user, options).then(excludeNonPushEvents);
};

0 comments on commit 5c065af

Please sign in to comment.