@zwa73/utils 1.0.89 → 1.0.90
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.d.ts +1 -1
- package/dist/UtilFunctions.js +3 -5
- package/package.json +1 -1
- package/src/UtilFunctions.ts +3 -6
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export declare class UtilFunc {
|
|
|
103
103
|
* @param task - 任务逻辑
|
|
104
104
|
* @returns 处理结果
|
|
105
105
|
*/
|
|
106
|
-
static queueProc<T>(flag: Keyable, task: (() => Promise<T>)
|
|
106
|
+
static queueProc<T>(flag: Keyable, task: (() => Promise<T>)): Promise<T>;
|
|
107
107
|
/**队列获取目标的代办事件数
|
|
108
108
|
* @param flag - 队列标签
|
|
109
109
|
*/
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -301,7 +301,7 @@ class UtilFunc {
|
|
|
301
301
|
this.pendingMap[flag] = this.pendingMap[flag] ?? [];
|
|
302
302
|
const pending = this.pendingMap[flag];
|
|
303
303
|
//尝试解除下个任务的等待
|
|
304
|
-
const tryRes =
|
|
304
|
+
const tryRes = () => {
|
|
305
305
|
const thispd = pending;
|
|
306
306
|
const resolve = thispd.shift();
|
|
307
307
|
if (resolve)
|
|
@@ -313,10 +313,8 @@ class UtilFunc {
|
|
|
313
313
|
else
|
|
314
314
|
await new Promise((resolve) => pending.push(resolve));
|
|
315
315
|
try {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
: await task;
|
|
319
|
-
return result;
|
|
316
|
+
return await task();
|
|
317
|
+
;
|
|
320
318
|
}
|
|
321
319
|
catch (e) {
|
|
322
320
|
UtilLogger_1.SLogger.fatal(`queuePromise 出现错误`, e);
|
package/package.json
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -356,12 +356,12 @@ static pendingMap:Record<Keyable,AnyFunc[]> = {};
|
|
|
356
356
|
* @param task - 任务逻辑
|
|
357
357
|
* @returns 处理结果
|
|
358
358
|
*/
|
|
359
|
-
static async queueProc<T>(flag:Keyable,task:(()=>Promise<T>)
|
|
359
|
+
static async queueProc<T>(flag:Keyable,task:(()=>Promise<T>)):Promise<T> {
|
|
360
360
|
this.pendingMap[flag] = this.pendingMap[flag]??[];
|
|
361
361
|
const pending = this.pendingMap[flag];
|
|
362
362
|
|
|
363
363
|
//尝试解除下个任务的等待
|
|
364
|
-
const tryRes =
|
|
364
|
+
const tryRes = () => {
|
|
365
365
|
const thispd = pending;
|
|
366
366
|
const resolve = thispd.shift();
|
|
367
367
|
if(resolve) resolve();
|
|
@@ -373,10 +373,7 @@ static async queueProc<T>(flag:Keyable,task:(()=>Promise<T>)|Promise<T>):Promise
|
|
|
373
373
|
else await new Promise((resolve) => pending.push(resolve));
|
|
374
374
|
|
|
375
375
|
try {
|
|
376
|
-
|
|
377
|
-
? await task()
|
|
378
|
-
: await task;
|
|
379
|
-
return result;
|
|
376
|
+
return await task();;
|
|
380
377
|
} catch(e){
|
|
381
378
|
SLogger.fatal(`queuePromise 出现错误`,e);
|
|
382
379
|
throw e;
|