@e-mc/request 0.11.4 → 0.11.5

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.11.4/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.5/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IModule, ModuleConstructor } from "./index";
@@ -209,9 +209,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
209
209
 
210
210
  ## References
211
211
 
212
- - https://www.unpkg.com/@e-mc/types@0.11.4/lib/http.d.ts
213
- - https://www.unpkg.com/@e-mc/types@0.11.4/lib/request.d.ts
214
- - https://www.unpkg.com/@e-mc/types@0.11.4/lib/settings.d.ts
212
+ - https://www.unpkg.com/@e-mc/types@0.11.5/lib/http.d.ts
213
+ - https://www.unpkg.com/@e-mc/types@0.11.5/lib/request.d.ts
214
+ - https://www.unpkg.com/@e-mc/types@0.11.5/lib/settings.d.ts
215
215
 
216
216
  * https://www.npmjs.com/package/@types/node
217
217
 
@@ -359,6 +359,7 @@ class HttpAdapter {
359
359
  this.terminate("No data received");
360
360
  return;
361
361
  }
362
+ dataLength = this.contentLength || (typeof this.pipeTo === 'string' ? (0, util_1.getSize)(this.pipeTo) : 0);
362
363
  result = encoding && !pipeline ? '' : null;
363
364
  }
364
365
  this.endResponse(result, dataLength, log);
@@ -371,12 +372,11 @@ class HttpAdapter {
371
372
  }
372
373
  endResponse(result, dataLength = 0, logging = this.state.log) {
373
374
  if (logging) {
374
- const messageUnit = this.dataTime && dataLength > 0 ? (0, util_1.getTransferRate)(dataLength, (0, types_1.convertTime)(process.hrtime.bigint() - this.dataTime, false) * 1000) : undefined;
375
375
  this.instance.writeTimeProcess('HTTP' + this.httpVersion, this.opts.statusMessage || this.uri.toString(), this.startTime, {
376
376
  type: 1024,
377
377
  queue: !!this.instance.host,
378
378
  titleBgColor: !result ? 'bgBlue' : undefined,
379
- messageUnit,
379
+ messageUnit: this.formatMibs(dataLength),
380
380
  messageUnitMinWidth: 9,
381
381
  delayTime: this.delayTime,
382
382
  bypassLog: module_1.hasLogType(32768)
@@ -488,6 +488,11 @@ class HttpAdapter {
488
488
  formatStatus(value, hint) {
489
489
  return value + ': ' + (hint || (0, util_1.fromStatusCode)(value)) + ` (${this.uri.toString()})`;
490
490
  }
491
+ formatMibs(dataLength) {
492
+ if (dataLength > 0 && this.dataTime) {
493
+ return (0, util_1.getTransferRate)(dataLength, Math.max(1, (0, types_1.convertTime)(process.hrtime.bigint() - this.dataTime, false) * 1000));
494
+ }
495
+ }
491
496
  close() {
492
497
  this.closed = true;
493
498
  this.instance.reset(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
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": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.11.4",
24
- "@e-mc/types": "0.11.4",
23
+ "@e-mc/module": "0.11.5",
24
+ "@e-mc/types": "0.11.5",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "picomatch": "^4.0.2",