@e-mc/request 0.8.28 → 0.8.30

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.
Files changed (3) hide show
  1. package/README.md +4 -4
  2. package/index.js +12 -10
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.28/lib/index.d.ts
12
+ - https://www.unpkg.com/@e-mc/types@0.8.30/lib/index.d.ts
13
13
 
14
14
  ```typescript
15
15
  import type { IModule, ModuleConstructor } from "./index";
@@ -82,9 +82,9 @@ interface RequestConstructor extends ModuleConstructor {
82
82
 
83
83
  ## References
84
84
 
85
- - https://www.unpkg.com/@e-mc/types@0.8.28/lib/http.d.ts
86
- - https://www.unpkg.com/@e-mc/types@0.8.28/lib/request.d.ts
87
- - https://www.unpkg.com/@e-mc/types@0.8.28/lib/settings.d.ts
85
+ - https://www.unpkg.com/@e-mc/types@0.8.30/lib/http.d.ts
86
+ - https://www.unpkg.com/@e-mc/types@0.8.30/lib/request.d.ts
87
+ - https://www.unpkg.com/@e-mc/types@0.8.30/lib/settings.d.ts
88
88
 
89
89
  ## LICENSE
90
90
 
package/index.js CHANGED
@@ -159,11 +159,17 @@ function getProxySettings(request, agentTimeout) {
159
159
  return null;
160
160
  }
161
161
  function closeTorrent(pid) {
162
- const index = ARIA2.PID_QUEUE.findIndex(value => pid === value[0]);
162
+ const index = ARIA2.PID_QUEUE.findIndex(value => value[0] === pid);
163
163
  if (index !== -1) {
164
164
  ARIA2.PID_QUEUE.splice(index, 1);
165
165
  }
166
166
  }
167
+ function resetAria2() {
168
+ if (ARIA2.PID_TIMER) {
169
+ clearInterval(ARIA2.PID_TIMER);
170
+ ARIA2.PID_TIMER = null;
171
+ }
172
+ }
167
173
  function clearDnsLookup() {
168
174
  DNS.CACHE = Object.create(null);
169
175
  DNS.TIMEOUT.forEach(value => clearTimeout(value));
@@ -181,7 +187,7 @@ function resetHttpHost(version) {
181
187
  const host = HTTP.HOST[origin];
182
188
  if (host.secure && host.version === 1) {
183
189
  const failed = host.failed(2, true);
184
- if (failed === 0 && host.failed(2, true) < 10 || failed < 3 && host.success(2, true) > 0) {
190
+ if (failed === 0 && host.error(2, true) < 10 || failed < 3 && host.success(2, true) > 0) {
185
191
  host.version = version;
186
192
  }
187
193
  }
@@ -1293,7 +1299,7 @@ class Request extends module_1.default {
1293
1299
  const pattern = new RegExp(`^${leading}(?:=|$)`);
1294
1300
  for (let i = 0; i < opts.length; ++i) {
1295
1301
  if (pattern.test(opts[i])) {
1296
- opts.splice(i--, i);
1302
+ opts.splice(i, 1);
1297
1303
  break;
1298
1304
  }
1299
1305
  }
@@ -1374,13 +1380,9 @@ class Request extends module_1.default {
1374
1380
  stderr.setEncoding('utf-8').on('data', (value) => message += value);
1375
1381
  if (pid !== undefined && module_1.default.isFile(uri, 'torrent')) {
1376
1382
  if (!ARIA2.PID_TIMER) {
1377
- const clearTimer = () => {
1378
- clearInterval(ARIA2.PID_TIMER);
1379
- ARIA2.PID_TIMER = null;
1380
- };
1381
1383
  ARIA2.PID_TIMER = setInterval(() => {
1382
1384
  if (ARIA2.PID_QUEUE.length === 0) {
1383
- clearTimer();
1385
+ resetAria2();
1384
1386
  return;
1385
1387
  }
1386
1388
  for (const item of ARIA2.PID_QUEUE) {
@@ -1415,7 +1417,7 @@ class Request extends module_1.default {
1415
1417
  ARIA2.PID_QUEUE.push(item);
1416
1418
  }
1417
1419
  else {
1418
- clearTimer();
1420
+ resetAria2();
1419
1421
  }
1420
1422
  }
1421
1423
  }, (ARIA2.UPDATE_STATUS || 30) * 1000);
@@ -2073,7 +2075,7 @@ class Request extends module_1.default {
2073
2075
  result = buffer;
2074
2076
  }
2075
2077
  }
2076
- else if (enabled && this.readExpect === 'always') {
2078
+ else if (enabled && !empty && this.readExpect === 'always') {
2077
2079
  throwError('No data received');
2078
2080
  return;
2079
2081
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.8.28",
3
+ "version": "0.8.30",
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.8.28",
24
- "@e-mc/types": "0.8.28",
23
+ "@e-mc/module": "0.8.30",
24
+ "@e-mc/types": "0.8.30",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "picomatch": "^3.0.1",