Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

attempt to deprecate per_page with paging behavior by default.

  • Loading branch information...
commit 8c63d2e5d26066e55d8842be98e25e2bacf8f71f 1 parent 42b6dbd
@chjj authored
Showing with 14 additions and 5 deletions.
  1. +14 −5 lib/charged.js
View
19 lib/charged.js
@@ -937,16 +937,23 @@ Charged.prototype.get = function(path, query, callback, format) {
query = null;
}
- // Per page:
+ // Per page limits:
// subscriptions, component usages: 200
// customers: 50
// statement-ids: 10000
if (query && query.per_page > 50 && query.page == null) {
- var max = query.per_page
+ // console.error('per_page detected for large number of results.');
+ // console.error('Please use query.max instead.');
+ query.max = query.per_page;
+ delete query.per_page;
+ }
+
+ if (query && query.max) {
+ var max = query.max
, out = []
- , concurrency
- , pending = 0;
+ , pending = 0
+ , concurrency;
if (query.concurrency) {
concurrency = query.concurrency;
@@ -961,7 +968,9 @@ Charged.prototype.get = function(path, query, callback, format) {
var cb = function(err) {
// If `out` is maxed, execute callback even
// if there are still requests pending.
- if (pending > 0 && out.length < max) return;
+ if (pending > 0 && out.length < max) {
+ return;
+ }
if (cb.done) return;
cb.done = true;
Please sign in to comment.
Something went wrong with that request. Please try again.