Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hubkit

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hubkit - npm Package Compare versions

Comparing version 0.6.5 to 0.7.0

.eslintrc.js

2

bower.json
{
"name": "hubkit",
"version": "0.6.5",
"version": "0.7.0",
"homepage": "https://github.com/pkaminski/hubkit",

@@ -5,0 +5,0 @@ "authors": [

if (typeof require !== 'undefined') {
/* global require */
if (typeof superagent === 'undefined') superagent = require('superagent');

@@ -10,8 +11,12 @@ if (typeof LRUCache === 'undefined') LRUCache = require('lru-cache');

if (typeof angular !== 'undefined') {
/* global angular */
angular.module('hubkit', []).constant('Hubkit', Hubkit);
} else if (typeof module !== 'undefined') {
/* global module */
module.exports = Hubkit;
} else if (typeof self !== 'undefined') {
/* global self */
self.Hubkit = Hubkit;
} else if (typeof window !== 'undefined') {
/* global window */
window.Hubkit = Hubkit;

@@ -25,2 +30,6 @@ } else {

var NETWORK_ERROR_CODES = [
'ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT'
];
var Hubkit = function(options) {

@@ -92,4 +101,4 @@ options = defaults({}, options);

if (cachedItem && (
options.immutable ||
!options.fresh && (Date.now() < cachedItem.expiry || cachedItem.promise)
options.immutable ||
!options.fresh && (Date.now() < cachedItem.expiry || cachedItem.promise)
)) {

@@ -135,8 +144,7 @@ if (options.stats) {

if (value === undefined) {
if ([
'ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT'
].indexOf(error.code) >= 0 ||
[500, 502, 503, 504].indexOf(error.status) >= 0 ||
error.originalMessage === 'socket hang up' ||
error.originalMessage === 'Unexpected end of input') {
if (NETWORK_ERROR_CODES.indexOf(error.code) >= 0 ||
[500, 502, 503, 504].indexOf(error.status) >= 0 ||
error.originalMessage === 'socket hang up' ||
error.originalMessage === 'Unexpected end of input'
) {
value = Hubkit.RETRY;

@@ -216,6 +224,6 @@ options.agent = false;

if (error) {
if (/Origin is not allowed by Access-Control-Allow-Origin/.test(error.message) && (
options.corsSuccessFlags[options.host] ||
!cacheable && (options.method === 'GET' || options.method === 'HEAD')
)) {
if (/Origin is not allowed by Access-Control-Allow-Origin/.test(error.message) &&
(options.corsSuccessFlags[options.host] ||
!cacheable && (options.method === 'GET' || options.method === 'HEAD'))
) {
error.message = 'Request terminated abnormally, network may be offline';

@@ -233,3 +241,3 @@ }

} else if (!(res.ok || options.boolean && res.notFound && res.body &&
res.body.message === 'Not Found') || res.body && res.body.errors) {
res.body.message === 'Not Found') || res.body && !res.body.data && res.body.errors) {
if (cacheable) {

@@ -275,3 +283,3 @@ options.cache.del(cacheKey);

nextUrl = match && match[1];
if (nextUrl && !(options.method == 'GET' || options.method === 'HEAD')) {
if (nextUrl && !(options.method === 'GET' || options.method === 'HEAD')) {
throw new Error(formatError('Hubkit', 'paginated response for non-GET method'));

@@ -305,2 +313,14 @@ }

}
if (data.errors && data.errors.length) {
outer: for (var j = 0; j < data.errors.length; j++) {
var nextError = data.errors[j];
if (result.errors && result.errors.length) {
for (var k = 0; k < result.errors.length; k++) {
if (result.errors[k].message === nextError.message) continue outer;
}
}
result.errors = result.errors || [];
result.errors.push(nextError);
}
}
}

@@ -316,17 +336,18 @@ if (endCursor) {

return; // Don't resolve yet, more pages to come
} else {
result.next = function() {
return self.request(
path,
defaults({
_cause: 'page', body: _.defaults({
variables: _.defaults({
after: endCursor
}, options.body.variables)
}, options.body)
}, options)
);
}
}
result.next = function() {
return self.request(
path,
defaults({
_cause: 'page', body: defaults({
variables: defaults({
after: endCursor
}, options.body.variables)
}, options.body)
}, options)
);
};
}
} else {
result = res.body;
}

@@ -352,7 +373,6 @@ } else if (res.body && (Array.isArray(res.body) || Array.isArray(res.body.items))) {

return; // Don't resolve yet, more pages to come.
} else {
result.next = function() {
return self.request(nextUrl, defaults({_cause: 'page', body: null}, options));
};
}
result.next = function() {
return self.request(nextUrl, defaults({_cause: 'page', body: null}, options));
};
}

@@ -374,3 +394,3 @@ } else {

var size = res.text ? res.text.length : (res.body ?
(res.body.size || res.body.byteLength) : 1);
(res.body.size || res.body.byteLength) : 1);
if (options.stats) options.stats.record(false, size);

@@ -465,4 +485,4 @@ if (res.status === 200 && (res.header.etag || res.header['cache-control']) &&

if (options.token) {
if (typeof module === 'undefined' && (
options.method === 'GET' || options.method === 'HEAD')) {
if (typeof module === 'undefined' &&
(options.method === 'GET' || options.method === 'HEAD')) {
req.query({'access_token': options.token});

@@ -479,6 +499,7 @@ } else {

if (options.media) req.accept('application/vnd.github.' + options.media);
req.query({per_page: options.perPage});
if (options.responseType) req.on('request', function() {
this.xhr.responseType = options.responseType;
});
req.query({per_page: options.perPage}); // eslint-disable-line camelcase
if (options.responseType) {
// eslint-disable-next-line no-invalid-this
req.on('request', function() {this.xhr.responseType = options.responseType;});
}
// Work around Firefox bug that forces caching. We can't use Cache-Control because it's not

@@ -511,3 +532,3 @@ // allowed by Github's cross-domain request headers, and because we want to keep our requests

for (var i = 0; i < scopes.length; i++) {
if (i === 0 || scopes[i-1] !== scopes[i]) metadata.oAuthScopes.push(scopes[i]);
if (i === 0 || scopes[i - 1] !== scopes[i]) metadata.oAuthScopes.push(scopes[i]);
}

@@ -514,0 +535,0 @@ }

{
"name": "hubkit",
"version": "0.6.5",
"version": "0.7.0",
"description": "GitHub API library for JavaScript, promise-based, for both NodeJS and the browser",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"release": "release-it"
},

@@ -30,3 +31,7 @@ "repository": {

"superagent": "^2.3.0"
},
"devDependencies": {
"eslint": "^4.18.1",
"release-it": "^7.2.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc