@e-mc/request 0.8.24 → 0.8.26

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
- - https://www.unpkg.com/@e-mc/types@0.8.24/lib/index.d.ts
12
+ - https://www.unpkg.com/@e-mc/types@0.8.26/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.24/lib/http.d.ts
86
- - https://www.unpkg.com/@e-mc/types@0.8.24/lib/request.d.ts
87
- - https://www.unpkg.com/@e-mc/types@0.8.24/lib/settings.d.ts
85
+ - https://www.unpkg.com/@e-mc/types@0.8.26/lib/http.d.ts
86
+ - https://www.unpkg.com/@e-mc/types@0.8.26/lib/request.d.ts
87
+ - https://www.unpkg.com/@e-mc/types@0.8.26/lib/settings.d.ts
88
88
 
89
89
  ## LICENSE
90
90
 
@@ -365,6 +365,7 @@ class HttpAdapter {
365
365
  this.terminate("No data received");
366
366
  return;
367
367
  }
368
+ dataLength = this.contentLength || (typeof this.pipeTo === 'string' ? (0, util_1.getSize)(this.pipeTo) : 0);
368
369
  result = encoding && !pipeline ? '' : null;
369
370
  }
370
371
  this.endResponse(result, dataLength, log);
@@ -377,12 +378,11 @@ class HttpAdapter {
377
378
  }
378
379
  endResponse(result, dataLength = 0, logging = this.state.log) {
379
380
  if (logging) {
380
- const messageUnit = this.dataTime && dataLength > 0 ? (0, util_1.getTransferRate)(dataLength, (0, types_1.convertTime)(process.hrtime.bigint() - this.dataTime, false) * 1000) : undefined;
381
381
  this.instance.writeTimeProcess('HTTP' + this.httpVersion, this.opts.statusMessage || this.uri.toString(), this.startTime, {
382
382
  type: 1024,
383
383
  queue: !!this.instance.host,
384
384
  titleBgColor: !result ? 'bgBlue' : undefined,
385
- messageUnit,
385
+ messageUnit: this.formatMibs(dataLength),
386
386
  messageUnitMinWidth: 9,
387
387
  delayTime: this.delayTime,
388
388
  bypassLog: module_1.hasLogType(32768)
@@ -494,6 +494,11 @@ class HttpAdapter {
494
494
  formatStatus(value, hint) {
495
495
  return value + ': ' + (hint || (0, util_1.fromStatusCode)(value)) + ` (${this.uri.toString()})`;
496
496
  }
497
+ formatMibs(dataLength) {
498
+ if (dataLength > 0 && this.dataTime) {
499
+ return (0, util_1.getTransferRate)(dataLength, Math.max(1, (0, types_1.convertTime)(process.hrtime.bigint() - this.dataTime, false) * 1000));
500
+ }
501
+ }
497
502
  close() {
498
503
  this.closed = true;
499
504
  this.instance.reset(this);
package/index.js CHANGED
@@ -2015,7 +2015,7 @@ class Request extends module_1.default {
2015
2015
  }
2016
2016
  }
2017
2017
  if (mibsTime) {
2018
- const unit = (Buffer.byteLength(buffer, encoding) * 8) / ((0, types_1.convertTime)(process.hrtime(mibsTime)) * 1000);
2018
+ const unit = (Buffer.byteLength(buffer, encoding) * 8) / Math.max(1, (0, types_1.convertTime)(process.hrtime(mibsTime)) * 1000);
2019
2019
  if (unit < 1) {
2020
2020
  messageUnit = Math.ceil(unit * 1000) + 'KiB/s';
2021
2021
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.8.24",
3
+ "version": "0.8.26",
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.24",
24
- "@e-mc/types": "0.8.24",
23
+ "@e-mc/module": "0.8.26",
24
+ "@e-mc/types": "0.8.26",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "picomatch": "^3.0.1",