@e-mc/request 0.12.6 → 0.12.8

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 CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.12.6/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.12.7/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IModule, ModuleConstructor } from "./index";
@@ -255,9 +255,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
255
255
 
256
256
  ## References
257
257
 
258
- - https://www.unpkg.com/@e-mc/types@0.12.6/lib/http.d.ts
259
- - https://www.unpkg.com/@e-mc/types@0.12.6/lib/request.d.ts
260
- - https://www.unpkg.com/@e-mc/types@0.12.6/lib/settings.d.ts
258
+ - https://www.unpkg.com/@e-mc/types@0.12.7/lib/http.d.ts
259
+ - https://www.unpkg.com/@e-mc/types@0.12.7/lib/request.d.ts
260
+ - https://www.unpkg.com/@e-mc/types@0.12.7/lib/settings.d.ts
261
261
 
262
262
  * https://www.npmjs.com/package/@types/node
263
263
 
@@ -14,19 +14,13 @@ class HttpAdapter {
14
14
  return value === 421 || value === 505;
15
15
  }
16
16
  static isDowngrade(err) {
17
- return err instanceof Error && (err.code === 'ERR_HTTP2_ERROR' || this.isUnsupported(Math.abs(err.errno)));
17
+ return module_1.isErrorCode(err, 'ERR_HTTP2_ERROR') || err instanceof Error && this.isUnsupported(Math.abs(err.errno));
18
18
  }
19
19
  static wasAborted(err) {
20
20
  return err instanceof Error && err.message.startsWith("Aborted");
21
21
  }
22
22
  static isConnectionError(err) {
23
- switch (err instanceof Error && err.code) {
24
- case 'ETIMEDOUT':
25
- case 'ECONNRESET':
26
- return true;
27
- default:
28
- return false;
29
- }
23
+ return module_1.isErrorCode(err, 'ETIMEDOUT', 'ECONNRESET');
30
24
  }
31
25
  static defineHostConfig({ settings }) {
32
26
  const time_format = settings?.time_format;
package/index.js CHANGED
@@ -21,7 +21,7 @@ const host_1 = require("@e-mc/request/http/host");
21
21
  const adapter_1 = require("@e-mc/request/http/adapter");
22
22
  const kRequest = Symbol.for('request:constructor');
23
23
  const SUPPORTED_NODE20 = (0, types_1.supported)(20);
24
- const SUPPORTED_ZSTD = (0, types_1.supported)(23, 8) && typeof zlib.createZstdDecompress === 'function';
24
+ const SUPPORTED_ZSTD = (0, types_1.supported)(23, 8) || (0, types_1.supported)(22, 15, 0, true);
25
25
  const REGEXP_PEMCERT = /^-{3,}[ \t]*BEGIN[ \t].+\n-{3,}[ \t]*END[ \t][^-]+-{3,}$/s;
26
26
  const REGEXP_GLOBWITHIN = /\\\?|(?:(?<!\\)(?:\*|\[!?[^!\]]+\]|\{(?:[^,]+,)+[^}]+\}|[!?+*@]\((?:[^|]+\|)*[^)]+\)|\?.*\?|\?$))/;
27
27
  const REGEXP_RCLONE = /^rclone:\?/i;
@@ -482,24 +482,25 @@ function checkBinTarget(instance, name, uri, pathname, command, binOpts) {
482
482
  return pathname;
483
483
  }
484
484
  function checkBinOpts(init, binOpts) {
485
- if ((0, types_1.isArray)(binOpts)) {
486
- for (let i = 0; i < binOpts.length; ++i) {
487
- const leading = binOpts[i] + '=';
488
- for (const arg of init) {
489
- if (arg.startsWith(leading)) {
490
- const items = [];
491
- for (let k = i + 1; k < binOpts.length; ++k) {
492
- const next = binOpts[k];
493
- if (next.startsWith('--')) {
494
- break;
495
- }
496
- items.push(next);
485
+ if (!binOpts) {
486
+ return;
487
+ }
488
+ for (let i = 0; i < binOpts.length; ++i) {
489
+ const leading = binOpts[i] + '=';
490
+ for (const arg of init) {
491
+ if (arg.startsWith(leading)) {
492
+ const items = [];
493
+ for (let k = i + 1; k < binOpts.length; ++k) {
494
+ const next = binOpts[k];
495
+ if (next.startsWith('--')) {
496
+ break;
497
497
  }
498
- const l = items.length + 1;
499
- binOpts.splice(i, l);
500
- i += l;
501
- break;
498
+ items.push(next);
502
499
  }
500
+ const l = items.length + 1;
501
+ binOpts.splice(i, l);
502
+ i += l;
503
+ break;
503
504
  }
504
505
  }
505
506
  }
@@ -514,7 +515,7 @@ function setBinHeaders(args, headers) {
514
515
  }
515
516
  }
516
517
  function finalizeBinArgs(instance, name, bin, args, opts, binOpts, cmd = []) {
517
- if ((0, types_1.isArray)(binOpts)) {
518
+ if (binOpts) {
518
519
  for (const leading of binOpts) {
519
520
  if (leading.startsWith('-')) {
520
521
  const pattern = new RegExp(`^${leading}(?:=|$)`);
@@ -554,7 +555,7 @@ const trimCharEnd = (value) => value.substring(0, value.length - 1);
554
555
  const configureDns = (family, options) => family === 0 ? options : { family, hints: family === 6 ? dns.V4MAPPED : 0 };
555
556
  const ignoreOpt = (opts, ...values) => !opts?.some(opt => values.some(value => opt === value || opt.startsWith(value + '=')));
556
557
  const escapeQuote = (value) => value.replace(/[\\"]/g, capture => '\\' + capture);
557
- const rcloneSize = (value) => (0, types_1.isString)(value) ? /^\d+(?:B|K|M|G|T|P)$/.exec(value)?.[0] : undefined;
558
+ const rcloneSize = (value) => (0, types_1.isString)(value) ? /^\d+(?:B|[KMGTP]i?)$/i.exec(value)?.[0] : undefined;
558
559
  const rcloneDuration = (value) => (0, types_1.isString)(value) ? /^\d+(?:h|m|s|ms|ns)$/.exec(value)?.[0] : undefined;
559
560
  class Request extends module_1 {
560
561
  static [kRequest] = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.12.6",
3
+ "version": "0.12.8",
4
4
  "description": "Request constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "license": "BSD-3-Clause",
20
20
  "homepage": "https://github.com/anpham6/e-mc#readme",
21
21
  "dependencies": {
22
- "@e-mc/module": "0.12.6",
23
- "@e-mc/types": "0.12.6",
22
+ "@e-mc/module": "0.12.8",
23
+ "@e-mc/types": "0.12.8",
24
24
  "combined-stream": "^1.0.8",
25
25
  "js-yaml": "^4.1.0",
26
26
  "picomatch": "^4.0.3",