Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Resolve test related to repo pagination for Node v4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Garant committed Jul 4, 2018
1 parent 0f7ef65 commit df52bfe
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ exports.load = function() {
const getSubsequentPages = (link, pagesCb) => {
if (github.hasNextPage(link)) {
github.getNextPage(link, (err, res) => {
if (err) { return pagesCb(err) }
if (err) {
return pagesCb(err)
}
results = res
return getSubsequentPages(res.meta.link, pagesCb)
})
Expand All @@ -50,24 +52,28 @@ exports.load = function() {
}

method(payload, (err, res) => {
if (err) { return cb(err, null) }
if (!Array.isArray(res)) { return cb(err, res) }
if (err) {
return cb(err, null)
}

if (!Array.isArray(res)) {
return cb(err, res)
}

results = res
getSubsequentPages(res.meta.link, (err) => {

getSubsequentPages(res.meta.link, err => {
cb(err, results)
})
})
}

return paginatedMethod
}

Object.entries(github.repos).forEach(([key, value]) => {
if (typeof value === 'function') {
github.repos[key] = paginate(value)
for (let key in github.repos) {
if (typeof github.repos[key] === 'function') {
github.repos[key] = paginate(github.repos[key])
}
})
}

exports.github = github
}
Expand Down

0 comments on commit df52bfe

Please sign in to comment.