@e-mc/request 0.9.18 → 0.9.20

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/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
- Copyright 2024 An Pham
1
+ Copyright 2025 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.9.18/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.20/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IModule, ModuleConstructor } from "./index";
@@ -202,9 +202,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
202
202
 
203
203
  ## References
204
204
 
205
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/http.d.ts
206
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/request.d.ts
207
- - https://www.unpkg.com/@e-mc/types@0.9.18/lib/settings.d.ts
205
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/http.d.ts
206
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/request.d.ts
207
+ - https://www.unpkg.com/@e-mc/types@0.9.20/lib/settings.d.ts
208
208
 
209
209
  * https://www.npmjs.com/package/@types/node
210
210
 
@@ -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
@@ -2049,7 +2049,7 @@ class Request extends module_1 {
2049
2049
  }
2050
2050
  dataLength = Buffer.byteLength(buffer, encoding);
2051
2051
  if (mibsTime) {
2052
- messageUnit = (0, util_1.getTransferRate)(dataLength, (0, types_1.convertTime)(process.hrtime(mibsTime), false) * 1000);
2052
+ messageUnit = (0, util_1.getTransferRate)(dataLength, Math.max(1, (0, types_1.convertTime)(process.hrtime(mibsTime), false) * 1000));
2053
2053
  }
2054
2054
  if (contentLength > 0) {
2055
2055
  parent.updateProgress("request", progressId, dataLength, dataLength);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "description": "Request constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,11 +17,11 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD-3-Clause",
20
+ "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.9.18",
24
- "@e-mc/types": "0.9.18",
23
+ "@e-mc/module": "0.9.20",
24
+ "@e-mc/types": "0.9.20",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "picomatch": "^4.0.2",