Comparing version 0.7.5 to 0.7.6
{ | ||
"name": "hubkit", | ||
"version": "0.7.0", | ||
"version": "0.7.5", | ||
"homepage": "https://github.com/pkaminski/hubkit", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -288,8 +288,26 @@ if (typeof require !== 'undefined') { | ||
var data = res.body.data; | ||
var keys = data ? Object.keys(data) : []; | ||
var rootKey = keys.length === 1 ? keys[0] : undefined; | ||
var root = data && data[rootKey]; | ||
var root = data, rootKeys = []; | ||
while (true) { | ||
if (!root || Array.isArray(root) || typeof root === 'string' || | ||
typeof root === 'number') { | ||
root = undefined; | ||
break; | ||
} | ||
var keys = Object.keys(root); | ||
if (keys.length !== 1) break; | ||
rootKeys.push(keys[0]); | ||
root = root[keys[0]]; | ||
if (root.nodes) break; | ||
} | ||
var paginated = root && Array.isArray(root.nodes) && root.pageInfo && | ||
/^\s*query[^({]*\((|[^)]*[(,\s])\$after\s*:\s*String[),\s]/.test(options.body.query); | ||
if (result && !(paginated && result.data[rootKey])) { | ||
var resultRoot; | ||
if (paginated) { | ||
resultRoot = result && result.data; | ||
for (var p = 0; p < rootKeys.length; p++) { | ||
if (resultRoot === undefined) break; | ||
resultRoot = resultRoot[rootKeys[p]]; | ||
} | ||
} | ||
if (result && !(paginated && resultRoot && Array.isArray(resultRoot.nodes))) { | ||
throw new Error(formatError('Hubkit', 'unable to concatenate paged results')); | ||
@@ -303,3 +321,2 @@ } | ||
} else { | ||
var resultRoot = result.data[rootKey]; | ||
resultRoot.nodes = resultRoot.nodes.concat(root.nodes); | ||
@@ -306,0 +323,0 @@ for (var key in root) { |
{ | ||
"name": "hubkit", | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "GitHub API library for JavaScript, promise-based, for both NodeJS and the browser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170298
712