@zwa73/utils 1.0.241 → 1.0.242
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/UtilHttp.d.ts +0 -5
- package/dist/UtilHttp.js +5 -3
- package/package.json +1 -1
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,17 @@ 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,
|
|
386
|
+
//interval = 0,
|
|
387
|
+
...baseReqOpt } = option;
|
|
386
388
|
const plusTimeout = timeout + 1000;
|
|
387
389
|
const hasTimeLimit = timeout >= 10_000;
|
|
388
390
|
const flagName = `UtilCom.request ${protocol}${baseReqOpt.method} ${UtilFunctions_1.UtilFunc.genUUID()}`;
|
|
389
391
|
const reduceQueue = new js_utils_1.PromiseQueue();
|
|
390
392
|
let dataPromise = null;
|
|
391
393
|
//等待间隔
|
|
392
|
-
if
|
|
393
|
-
|
|
394
|
+
//if(UtilHttp.requestQueue.length>0 && interval>0)
|
|
395
|
+
// await UtilHttp.requestQueue.enqueue(async ()=>UtilFunc.sleep(interval));
|
|
394
396
|
return new Promise(async (resolve, rejecte) => {
|
|
395
397
|
const finallyTimeout = hasTimeLimit
|
|
396
398
|
? setTimeout(() => {
|