@e-mc/request 0.10.13 → 0.10.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/http/adapter/index.js +8 -8
- package/index.js +7 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.15/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IModule, ModuleConstructor } from "./index";
|
|
@@ -205,9 +205,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
|
|
|
205
205
|
|
|
206
206
|
## References
|
|
207
207
|
|
|
208
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
209
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
210
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
208
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/http.d.ts
|
|
209
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/request.d.ts
|
|
210
|
+
- https://www.unpkg.com/@e-mc/types@0.10.15/lib/settings.d.ts
|
|
211
211
|
|
|
212
212
|
* https://www.npmjs.com/package/@types/node
|
|
213
213
|
|
package/http/adapter/index.js
CHANGED
|
@@ -5,28 +5,28 @@ const yaml = require("js-yaml");
|
|
|
5
5
|
const types_1 = require("@e-mc/types");
|
|
6
6
|
const module_1 = require("@e-mc/module");
|
|
7
7
|
const util_1 = require("@e-mc/request/util");
|
|
8
|
+
const kHttpAdapter = Symbol.for('request:http:adapter:constructor');
|
|
8
9
|
let LOG_TIMEFORMAT = 'readable';
|
|
10
|
+
const isConstructor = (value) => typeof value === 'function' && !!value.prototype?.constructor.name;
|
|
9
11
|
class HttpAdapter {
|
|
10
12
|
instance;
|
|
11
13
|
state;
|
|
12
14
|
uri;
|
|
15
|
+
static [kHttpAdapter] = true;
|
|
16
|
+
static constructorOf(value) {
|
|
17
|
+
return isConstructor(value) && value[kHttpAdapter] === true;
|
|
18
|
+
}
|
|
13
19
|
static isUnsupported(value) {
|
|
14
20
|
return value === 421 || value === 505;
|
|
15
21
|
}
|
|
16
22
|
static isDowngrade(err) {
|
|
17
|
-
return
|
|
23
|
+
return (0, types_1.isErrorCode)(err, 'ERR_HTTP2_ERROR') || err instanceof Error && this.isUnsupported(Math.abs(err.errno));
|
|
18
24
|
}
|
|
19
25
|
static wasAborted(err) {
|
|
20
26
|
return err instanceof Error && err.message.startsWith("Aborted");
|
|
21
27
|
}
|
|
22
28
|
static isConnectionError(err) {
|
|
23
|
-
|
|
24
|
-
case 'ETIMEDOUT':
|
|
25
|
-
case 'ECONNRESET':
|
|
26
|
-
return true;
|
|
27
|
-
default:
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
29
|
+
return (0, types_1.isErrorCode)(err, 'ETIMEDOUT', 'ECONNRESET');
|
|
30
30
|
}
|
|
31
31
|
static defineHostConfig({ settings }) {
|
|
32
32
|
const time_format = settings?.time_format;
|
package/index.js
CHANGED
|
@@ -1237,7 +1237,7 @@ class Request extends module_1 {
|
|
|
1237
1237
|
break;
|
|
1238
1238
|
}
|
|
1239
1239
|
if (expires !== undefined) {
|
|
1240
|
-
if (
|
|
1240
|
+
if ((0, types_1.isString)(expires)) {
|
|
1241
1241
|
expires = (0, types_1.parseExpires)(expires);
|
|
1242
1242
|
}
|
|
1243
1243
|
if (expires >= 0) {
|
|
@@ -1468,8 +1468,12 @@ class Request extends module_1 {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
break;
|
|
1470
1470
|
case 'readExpect':
|
|
1471
|
-
|
|
1472
|
-
|
|
1471
|
+
switch (value) {
|
|
1472
|
+
case 'string':
|
|
1473
|
+
case 'always':
|
|
1474
|
+
case 'none':
|
|
1475
|
+
this[name] = value;
|
|
1476
|
+
break;
|
|
1473
1477
|
}
|
|
1474
1478
|
break;
|
|
1475
1479
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/request",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.15",
|
|
4
4
|
"description": "Request constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.10.
|
|
24
|
-
"@e-mc/types": "0.10.
|
|
23
|
+
"@e-mc/module": "0.10.15",
|
|
24
|
+
"@e-mc/types": "0.10.15",
|
|
25
25
|
"combined-stream": "^1.0.8",
|
|
26
26
|
"js-yaml": "^4.1.0",
|
|
27
27
|
"picomatch": "^4.0.2",
|