diff --git a/.lib.eslintrc b/.lib.eslintrc
index 3a7b69619..9c0df042b 100644
--- a/.lib.eslintrc
+++ b/.lib.eslintrc
@@ -4,7 +4,8 @@
"node/no-deprecated-api": "off",
"no-console": "off",
"no-unused-vars": "off",
- "no-empty": "off"
+ "no-empty": "off",
+ "node/no-unsupported-features/node-builtins": "off"
},
"overrides": [
{
diff --git a/README.md b/README.md
index da9e2b623..322209085 100644
--- a/README.md
+++ b/README.md
@@ -83,8 +83,7 @@ Browser-ready versions of this module are available via [jsdelivr][], [unpkg][],
This is the solution for you if you're just using `
+
diff --git a/package.json b/package.json
index 971fb13f6..f34174a54 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,8 @@
"methods": "^1.1.2",
"mime": "^2.4.0",
"qs": "^6.7.0",
- "readable-stream": "^3.2.0"
+ "readable-stream": "^3.2.0",
+ "semver": "^6.0.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
@@ -72,7 +73,7 @@
"zuul": "^3.12.0"
},
"engines": {
- "node": ">= 8.8.1"
+ "node": ">= 6.4.0"
},
"homepage": "https://github.com/visionmedia/superagent",
"husky": {
diff --git a/src/node/agent.js b/src/node/agent.js
index cb1a71c8c..283c220ad 100644
--- a/src/node/agent.js
+++ b/src/node/agent.js
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies.
*/
diff --git a/src/node/http2wrapper.js b/src/node/http2wrapper.js
index af9d7e3bc..cb75538a2 100644
--- a/src/node/http2wrapper.js
+++ b/src/node/http2wrapper.js
@@ -1,12 +1,15 @@
-'use strict';
-
-const http2 = require('http2');
const Stream = require('stream');
const util = require('util');
const net = require('net');
const tls = require('tls');
// eslint-disable-next-line node/no-deprecated-api
const { parse } = require('url');
+const semver = require('semver');
+
+let http2;
+if (semver.gte(process.version, 'v10.10.0')) http2 = require('http2');
+else
+ throw new Error('superagent: this version of Node.js does not support http2');
const {
HTTP2_HEADER_PATH,
diff --git a/src/node/index.js b/src/node/index.js
index bb7b2f7bb..3722da46b 100644
--- a/src/node/index.js
+++ b/src/node/index.js
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies.
*/
@@ -19,6 +17,8 @@ const FormData = require('form-data');
const formidable = require('formidable');
const debug = require('debug')('superagent');
const CookieJar = require('cookiejar');
+const semver = require('semver');
+
const utils = require('../utils');
const pkg = require('../../package.json');
const RequestBase = require('../request-base');
@@ -26,9 +26,8 @@ const { unzip } = require('./unzip');
const Response = require('./response');
let http2;
-try {
- http2 = require('./http2wrapper');
-} catch (_) {}
+
+if (semver.gte(process.version, 'v10.10.0')) http2 = require('./http2wrapper');
function request(method, url) {
// callback
diff --git a/src/node/response.js b/src/node/response.js
index d88b5e1aa..b53275ae4 100644
--- a/src/node/response.js
+++ b/src/node/response.js
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies.
*/
diff --git a/src/node/unzip.js b/src/node/unzip.js
index e882a336c..2f2436aaa 100644
--- a/src/node/unzip.js
+++ b/src/node/unzip.js
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* Module dependencies.
*/
diff --git a/src/request-base.js b/src/request-base.js
index 63b23c471..749101b79 100644
--- a/src/request-base.js
+++ b/src/request-base.js
@@ -260,12 +260,10 @@ RequestBase.prototype.then = function(resolve, reject) {
});
}
- // eslint-disable-next-line promise/prefer-await-to-then
return this._fullfilledPromise.then(resolve, reject);
};
RequestBase.prototype.catch = function(cb) {
- // eslint-disable-next-line promise/prefer-await-to-then
return this.then(undefined, cb);
};
diff --git a/yarn.lock b/yarn.lock
index 09ddbfa0f..85a923e7e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1960,14 +1960,14 @@ camelcase@^5.0.0:
integrity sha512-IXFsBS2pC+X0j0N/GE7Dm7j3bsEBp+oTpb7F50dwEVX7rf3IgwO9XatnegTsDtniKCUtEJH4fSU6Asw7uoVLfQ==
caniuse-db@^1.0.30000951:
- version "1.0.30000954"
- resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000954.tgz#ab9b0000d92a055747f380701684b9c9d017fca4"
- integrity sha512-Rwd/JRb1/7wXzSOS5AQHXp4RBWXeNNPZW/9Gmv1kfO14ayrssFOM+vbu/0CPkYOCSZK6QZGMlrzaXznGLPkBAA==
+ version "1.0.30000955"
+ resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000955.tgz#d638a170f94654d77eff7821ec33b51dcd1330b0"
+ integrity sha512-VNb239mObbXMw9fWhd31idGYBG1gNBQc/qjUWa+ldoeWnjAkoeTZOowTMnVwcCiaMjbC7DNYw8YFkfdFlWLJrA==
caniuse-lite@^1.0.30000951, caniuse-lite@^1.0.30000954:
- version "1.0.30000954"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000954.tgz#227c2743e40f07c71e6683b6ca9491bfd5755b8e"
- integrity sha512-Wopmc0eVSSG1d9/O4JTn0OmGhUfhEHNkHhoCjUrGSImvHI+2YQWkOI1RRNTUFNSHbSAD8J41jbdZrPP4r32cbQ==
+ version "1.0.30000955"
+ resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000955.tgz#360fdb9a1e41d6dd996130411334e44a39e4446d"
+ integrity sha512-6AwmIKgqCYfDWWadRkAuZSHMQP4Mmy96xAXEdRBlN/luQhlRYOKgwOlZ9plpCOsVbBuqbTmGqDK3JUM/nlr8CA==
capture-stack-trace@^1.0.0:
version "1.0.1"
@@ -3431,9 +3431,9 @@ eslint-plugin-unicorn@^7.0.0:
safe-regex "^2.0.1"
eslint-rule-docs@^1.1.5:
- version "1.1.85"
- resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.85.tgz#ba8a4629457da916b361576495670428c125984a"
- integrity sha512-CrNaaB1aYymFbuyMkEDC2u/+p8T7UrIbi9u6ASTjoIYD6zLhPXHttYAwjS+8D+1FDMXjf03ByT04MUMlqUDKng==
+ version "1.1.86"
+ resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.86.tgz#e3420659a19d48f137cecd04fc1f5f0957b54e22"
+ integrity sha512-9H+Yv0UlEeNPjKPBge1G1x366GY1SbRQZNxwkYh89MaCgciNwJAk62XoaE9DvaY4DPZ1uN5Z7z5k8UsINwcPJg==
eslint-scope@^4.0.3:
version "4.0.3"
@@ -3496,9 +3496,9 @@ eslint@^5.12.0, eslint@^5.15.3:
text-table "^0.2.0"
esm@^3.0.82:
- version "3.2.20"
- resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.20.tgz#44f125117863427cdece7223baa411fc739c1939"
- integrity sha512-NA92qDA8C/qGX/xMinDGa3+cSPs4wQoFxskRrSnDo/9UloifhONFm4sl4G+JsyCqM007z2K+BfQlH5rMta4K1Q==
+ version "3.2.21"
+ resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.21.tgz#9cf6f1d7c70e22a641534f88ac01d6a1de5ba0a5"
+ integrity sha512-DkNi6jYtrT/FdO8pPEH+GFtBE321T3nup8FWdgaYpzaf4tK6aVJiCfgxNotZjEbnZ32t2VEtqIfbjp5GBN65Nw==
espree@^4.0.0:
version "4.1.0"
@@ -7203,9 +7203,9 @@ pako@~1.0.5:
integrity sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==
parent-module@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.0.tgz#df250bdc5391f4a085fb589dad761f5ad6b865b5"
- integrity sha512-8Mf5juOMmiE4FcmzYc4IaiS9L3+9paz2KOiXzkRviCP6aDmN49Hz6EMWz0lGNp9pX80GvvAuLADtyGfW/Em3TA==
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
+ integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==
dependencies:
callsites "^3.0.0"
@@ -8014,7 +8014,7 @@ remark-heading-gap@^3.0.0:
resolved "https://registry.yarnpkg.com/remark-heading-gap/-/remark-heading-gap-3.1.0.tgz#6a1851b4226fa82441ae1365bbd599d34b12d812"
integrity sha512-KxH9CTgfDnVTZVMMLJRw73zxZSWGX+p6x/trG7ed2UsEYqMRr8Dqtu/SXp2vD1ZZhPM8CpS7SjS+qjmiaRFotw==
-remark-license@niftylettuce/remark-license:
+"remark-license@github:niftylettuce/remark-license":
version "4.0.1"
resolved "https://codeload.github.com/niftylettuce/remark-license/tar.gz/17ecb8f64f8f6082414d14f9267a12764e6ddbfb"
dependencies:
@@ -9006,6 +9006,11 @@ semver@5.6.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
+semver@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65"
+ integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==
+
send@0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/send/-/send-0.1.4.tgz#be70d8d1be01de61821af13780b50345a4f71abd"