Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix cb.done in paging.

  • Loading branch information...
commit 4b3ad42b9d25b2fc87320b822e7bc50cedec055c 1 parent 33fb7a3
@chjj authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/charged.js
View
13 lib/charged.js
@@ -1001,18 +1001,21 @@ Charged.prototype._page = function(path, query, callback, format) {
query.per_page = max;
function cb(err) {
+ if (cb.done) return;
+
+ if (err) {
+ cb.done = true;
+ return callback(err);
+ }
+
// If `out` is maxed, execute callback even
// if there are still requests pending.
if (pending && out.length < max) {
return;
}
- if (cb.done) return;
cb.done = true;
-
- return err
- ? callback(err)
- : callback(null, out);
+ return callback(null, out);
}
function page() {
Please sign in to comment.
Something went wrong with that request. Please try again.