external-ip
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -24,4 +24,4 @@ 'use strict'; | ||
sequential: (cb) => { | ||
let errors = []; | ||
let current = 0; | ||
let errors = []; | ||
@@ -32,5 +32,5 @@ const loop = () => { | ||
errors.push(error); | ||
current += 1; | ||
current +=1; | ||
// when every single service has failed tell the bad news | ||
if (current === requests.length) { | ||
if (errors.length === requests.length) { | ||
return cb(utils.concatErrors(errors), null); | ||
@@ -51,13 +51,3 @@ } | ||
const abort = (requests) => { | ||
process.nextTick(() => { | ||
requests.forEach((request) => { | ||
request.abort(); | ||
}); | ||
}); | ||
}; | ||
const onResponse = (err, ip) => { | ||
let onResponse = function (err, ip) { | ||
if (done) { | ||
@@ -71,3 +61,9 @@ return; | ||
done = true; | ||
abort(ongoingRequests); //async | ||
ongoingRequests.forEach((request) => { | ||
if (this === request) { | ||
return; | ||
} | ||
request.abort(); | ||
}); | ||
ongoingRequests = null; | ||
return cb(null, ip); | ||
@@ -74,0 +70,0 @@ } |
@@ -5,3 +5,3 @@ 'use strict'; | ||
const net = require('net'); | ||
const request = require('request'); | ||
const get = require('simple-get'); | ||
@@ -57,3 +57,3 @@ /** | ||
return (cb) => { | ||
return request.get({ | ||
return get.concat({ | ||
url: url, | ||
@@ -64,6 +64,5 @@ timeout: config.timeout, | ||
} | ||
}, (error, res, body = '') => { | ||
// if the body is null use an empty string | ||
}, (error, res, body = '') => { // if the body is falsey use an empty string | ||
if (error) { | ||
return cb(new Error(`${error.code} from ${url}`), null); | ||
return cb(new Error(`${error.message} from ${url}`), null); | ||
} | ||
@@ -70,0 +69,0 @@ // Parse and validate the body |
{ | ||
"name": "external-ip", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A node.js library to get your external ip from multiple services", | ||
@@ -38,4 +38,4 @@ "main": "index.js", | ||
"commander": "^2.9.0", | ||
"request": "^2.81.0", | ||
"revalidator": "^0.3.1" | ||
"revalidator": "^0.3.1", | ||
"simple-get": "^2.6.0" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
@@ -12,2 +12,3 @@ 'http://ip.appspot.com/', | ||
test cli | ||
npm badge | ||
https://www.npmjs.com/package/simple-get |
19602
371
+ Addedsimple-get@^2.6.0
+ Addeddecompress-response@3.3.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@2.8.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedrequest@^2.81.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.0(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)