@zwa73/utils 1.0.241 → 1.0.243
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/dist/UtilFunctions.js +3 -4
- package/dist/UtilHttp.d.ts +0 -5
- package/dist/UtilHttp.js +1 -4
- package/package.json +2 -2
package/dist/UtilFunctions.js
CHANGED
|
@@ -125,11 +125,10 @@ class _UtilFunc {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
const key = '__jsUtils';
|
|
128
|
-
const
|
|
129
|
-
exports.UtilFunc = (0, modular_mixer_1.
|
|
130
|
-
base: _UtilFunc,
|
|
128
|
+
const fieldList = Object.getOwnPropertyNames(js_utils_1.JsFunc).filter(k => !['length', 'prototype', 'name'].includes(k));
|
|
129
|
+
exports.UtilFunc = (0, modular_mixer_1.composeClass)(_UtilFunc, {
|
|
131
130
|
mixin: js_utils_1.JsFunc,
|
|
132
|
-
key,
|
|
131
|
+
key, fieldList
|
|
133
132
|
});
|
|
134
133
|
//void (async ()=>{
|
|
135
134
|
// const p1 = UtilFunc.getNeverResolvedPromise();
|
package/dist/UtilHttp.d.ts
CHANGED
|
@@ -14,11 +14,6 @@ export type RequestResult<T> = {
|
|
|
14
14
|
};
|
|
15
15
|
/**网络请求选项 */
|
|
16
16
|
export type RequestOption = {
|
|
17
|
-
/**请求之间的间隔, 单位毫秒 默认 0
|
|
18
|
-
* 如果用promise并发请求可能会因缓冲区溢出导致req.write提前中断
|
|
19
|
-
* 为避免此问题需要设置请求间隔
|
|
20
|
-
*/
|
|
21
|
-
interval?: number;
|
|
22
17
|
/**请求协议 */
|
|
23
18
|
protocol: 'http:' | 'https:';
|
|
24
19
|
/**超时时间/毫秒 最小为10_000 默认无限 */
|
package/dist/UtilHttp.js
CHANGED
|
@@ -382,15 +382,12 @@ class UtilHttp {
|
|
|
382
382
|
static async request(option, sendProc, acceptProc) {
|
|
383
383
|
const { reduce: reqReduce, init: reqInit } = acceptProc;
|
|
384
384
|
const { proc: reqProc } = sendProc;
|
|
385
|
-
const { protocol, timeout = 0,
|
|
385
|
+
const { protocol, timeout = 0, ...baseReqOpt } = option;
|
|
386
386
|
const plusTimeout = timeout + 1000;
|
|
387
387
|
const hasTimeLimit = timeout >= 10_000;
|
|
388
388
|
const flagName = `UtilCom.request ${protocol}${baseReqOpt.method} ${UtilFunctions_1.UtilFunc.genUUID()}`;
|
|
389
389
|
const reduceQueue = new js_utils_1.PromiseQueue();
|
|
390
390
|
let dataPromise = null;
|
|
391
|
-
//等待间隔
|
|
392
|
-
if (UtilHttp.requestQueue.length > 0 && interval > 0)
|
|
393
|
-
await UtilHttp.requestQueue.enqueue(async () => UtilFunctions_1.UtilFunc.sleep(interval));
|
|
394
391
|
return new Promise(async (resolve, rejecte) => {
|
|
395
392
|
const finallyTimeout = hasTimeLimit
|
|
396
393
|
? setTimeout(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zwa73/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.243",
|
|
4
4
|
"description": "my utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@deepkit/type": "^1.0.1-alpha.153",
|
|
20
20
|
"@zwa73/js-utils": "*",
|
|
21
|
-
"@zwa73/modular-mixer": "
|
|
21
|
+
"@zwa73/modular-mixer": "^1.0.6",
|
|
22
22
|
"form-data": "^4.0.2",
|
|
23
23
|
"glob": "^10.4.1",
|
|
24
24
|
"handlebars": "^4.7.8",
|