@e-mc/request 0.8.3 → 0.8.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/LICENSE +7 -0
- package/README.md +4 -4
- package/index.js +25 -25
- package/package.json +4 -4
- package/util.js +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 Mile Square Park
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
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
package/index.js
CHANGED
|
@@ -722,7 +722,7 @@ class Request extends module_1.default {
|
|
|
722
722
|
const args = [];
|
|
723
723
|
for (let i = 0; i < log.length; ++i) {
|
|
724
724
|
const item = log[i];
|
|
725
|
-
if (Array.isArray(item[2]) && item[2][0].startsWith(origin)) {
|
|
725
|
+
if (item[1] === title && Array.isArray(item[2]) && item[2][0].startsWith(origin)) {
|
|
726
726
|
item[1] = '';
|
|
727
727
|
item[2][0] = item[2][0].substring(origin.length);
|
|
728
728
|
item[4].titleBgColor = undefined;
|
|
@@ -731,12 +731,17 @@ class Request extends module_1.default {
|
|
|
731
731
|
log.splice(i--, 1);
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
output.push([title, origin, value, args]);
|
|
734
|
+
output.push([title, origin, value, args.sort((a, b) => a[2][0] < b[2][0] ? -1 : 1)]);
|
|
735
735
|
count = Math.max(count, value);
|
|
736
736
|
}
|
|
737
737
|
});
|
|
738
738
|
if (LOG_STDOUT) {
|
|
739
|
-
output.sort((a, b) =>
|
|
739
|
+
output.sort((a, b) => {
|
|
740
|
+
if (a[2] === b[2]) {
|
|
741
|
+
return a[1] < b[1] ? -1 : 1;
|
|
742
|
+
}
|
|
743
|
+
return b[2] - a[2];
|
|
744
|
+
});
|
|
740
745
|
const width = count.toString().length;
|
|
741
746
|
output.forEach(item => {
|
|
742
747
|
const [title, origin, downloads, messages] = item;
|
|
@@ -779,7 +784,7 @@ class Request extends module_1.default {
|
|
|
779
784
|
}
|
|
780
785
|
init(config) {
|
|
781
786
|
if (config) {
|
|
782
|
-
const { headers, httpVersion, ipVersion, requestTimeout } = config;
|
|
787
|
+
const { headers, httpVersion, ipVersion, requestTimeout, readTimeout = requestTimeout } = config;
|
|
783
788
|
if ((0, types_1.isObject)(headers)) {
|
|
784
789
|
setOutgoingHeaders(this[kHeaders] || (this[kHeaders] = {}), headers);
|
|
785
790
|
}
|
|
@@ -789,8 +794,8 @@ class Request extends module_1.default {
|
|
|
789
794
|
if (ipVersion !== undefined) {
|
|
790
795
|
this.ipVersion = ipVersion;
|
|
791
796
|
}
|
|
792
|
-
if (
|
|
793
|
-
this.readTimeout = (0, util_1.fromSeconds)(
|
|
797
|
+
if (readTimeout !== undefined) {
|
|
798
|
+
this.readTimeout = (0, util_1.fromSeconds)(readTimeout);
|
|
794
799
|
}
|
|
795
800
|
}
|
|
796
801
|
return this;
|
|
@@ -950,35 +955,35 @@ class Request extends module_1.default {
|
|
|
950
955
|
}
|
|
951
956
|
}
|
|
952
957
|
}
|
|
953
|
-
statusOn(code,
|
|
954
|
-
if (typeof
|
|
955
|
-
callback =
|
|
956
|
-
|
|
958
|
+
statusOn(code, globUrl = '*', callback) {
|
|
959
|
+
if (typeof globUrl === 'function') {
|
|
960
|
+
callback = globUrl;
|
|
961
|
+
globUrl = '*';
|
|
957
962
|
}
|
|
958
|
-
if ((0, types_1.isString)(
|
|
963
|
+
if ((0, types_1.isString)(globUrl) && typeof callback === 'function') {
|
|
959
964
|
const on = this[kStatusOn] || (this[kStatusOn] = new Map());
|
|
960
965
|
for (const item of !Array.isArray(code) ? [code] : code) {
|
|
961
966
|
let status = on.get(item);
|
|
962
967
|
if (!status) {
|
|
963
968
|
on.set(item, status = []);
|
|
964
969
|
}
|
|
965
|
-
status.push([
|
|
970
|
+
status.push([globUrl, callback]);
|
|
966
971
|
}
|
|
967
972
|
}
|
|
968
973
|
}
|
|
969
|
-
headersOn(name,
|
|
970
|
-
if (typeof
|
|
971
|
-
callback =
|
|
972
|
-
|
|
974
|
+
headersOn(name, globUrl = '*', callback) {
|
|
975
|
+
if (typeof globUrl === 'function') {
|
|
976
|
+
callback = globUrl;
|
|
977
|
+
globUrl = '*';
|
|
973
978
|
}
|
|
974
|
-
if ((0, types_1.isString)(
|
|
979
|
+
if ((0, types_1.isString)(globUrl) && typeof callback === 'function') {
|
|
975
980
|
const on = this[kHeadersOn] || (this[kHeadersOn] = new Map());
|
|
976
981
|
for (const item of !Array.isArray(name) ? [name] : name) {
|
|
977
982
|
let headers = on.get(item);
|
|
978
983
|
if (!headers) {
|
|
979
984
|
on.set(item, headers = []);
|
|
980
985
|
}
|
|
981
|
-
headers.push([
|
|
986
|
+
headers.push([globUrl, callback]);
|
|
982
987
|
}
|
|
983
988
|
}
|
|
984
989
|
}
|
|
@@ -1464,7 +1469,7 @@ class Request extends module_1.default {
|
|
|
1464
1469
|
}
|
|
1465
1470
|
}
|
|
1466
1471
|
if (!proxy && httpVersion !== 1 && ((httpVersion || host.version) === 2 && version !== 1 || secure && version === 2 && host.failed(2, true) === 0)) {
|
|
1467
|
-
request = ((_p = this[kSession][0])[origin] || (_p[origin] = http2.connect(origin, { lookup: this.lookupDns(hostname), ca, cert, key, minVersion, settings: localhost ? {
|
|
1472
|
+
request = ((_p = this[kSession][0])[origin] || (_p[origin] = http2.connect(origin, { lookup: this.lookupDns(hostname), ca, cert, key, minVersion, settings: localhost ? { maxFrameSize: 16777215 /* CONSTANTS.MAX_FRAME_SIZE */, enablePush: false } : { enablePush: false } }))).request({ ...baseHeaders, ...host_1.default.getBasicAuth(url), ...headers, ':path': pathname, ':method': method });
|
|
1468
1473
|
if (getting) {
|
|
1469
1474
|
const listenerMap = {};
|
|
1470
1475
|
const onEvent = request.on.bind(request);
|
|
@@ -1921,9 +1926,6 @@ class Request extends module_1.default {
|
|
|
1921
1926
|
}, readTimeout);
|
|
1922
1927
|
}
|
|
1923
1928
|
if (log) {
|
|
1924
|
-
if (buffering === false) {
|
|
1925
|
-
mibsTime = process.hrtime();
|
|
1926
|
-
}
|
|
1927
1929
|
switch (this.settings?.time_format || LOG_TIMEFORMAT) {
|
|
1928
1930
|
case 'readable':
|
|
1929
1931
|
delayTime = process.hrtime(startTime);
|
|
@@ -1932,6 +1934,7 @@ class Request extends module_1.default {
|
|
|
1932
1934
|
delayTime = Date.now() - this.startTime;
|
|
1933
1935
|
break;
|
|
1934
1936
|
}
|
|
1937
|
+
mibsTime = process.hrtime();
|
|
1935
1938
|
}
|
|
1936
1939
|
});
|
|
1937
1940
|
}
|
|
@@ -1949,9 +1952,6 @@ class Request extends module_1.default {
|
|
|
1949
1952
|
}
|
|
1950
1953
|
}
|
|
1951
1954
|
else {
|
|
1952
|
-
if (log) {
|
|
1953
|
-
mibsTime = process.hrtime();
|
|
1954
|
-
}
|
|
1955
1955
|
buffer = typeof chunk === 'string' ? chunk : [chunk];
|
|
1956
1956
|
}
|
|
1957
1957
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/request",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
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": "
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.8.
|
|
24
|
-
"@e-mc/types": "0.8.
|
|
23
|
+
"@e-mc/module": "0.8.5",
|
|
24
|
+
"@e-mc/types": "0.8.5",
|
|
25
25
|
"combined-stream": "^1.0.8",
|
|
26
26
|
"js-yaml": "^4.1.0",
|
|
27
27
|
"picomatch": "^3.0.1",
|
package/util.js
CHANGED
|
@@ -138,9 +138,9 @@ exports.asFloat = asFloat;
|
|
|
138
138
|
function fromSeconds(value) {
|
|
139
139
|
switch (typeof value) {
|
|
140
140
|
case 'string':
|
|
141
|
-
return safeInt(
|
|
141
|
+
return safeInt(parseInt(value) * 1000 /* TIME.S */);
|
|
142
142
|
case 'number':
|
|
143
|
-
return safeInt(value * 1000 /* TIME.S */);
|
|
143
|
+
return safeInt(Math.trunc(value) * 1000 /* TIME.S */);
|
|
144
144
|
default:
|
|
145
145
|
return NaN;
|
|
146
146
|
}
|