cgserver 6.4.5 → 6.4.8
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/lib/Core/Core.js
CHANGED
|
@@ -570,29 +570,34 @@ class core {
|
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
572
|
try {
|
|
573
|
+
let rs = undefined;
|
|
573
574
|
if (core.isAsyncFunc(func)) {
|
|
574
575
|
if (thisArg) {
|
|
575
|
-
await func.call(thisArg, params).catch((reason) => {
|
|
576
|
+
rs = await func.call(thisArg, params).catch((reason) => {
|
|
576
577
|
Log_1.GLog.error(reason);
|
|
578
|
+
rs = { errcode: { id: 1008611, des: "failed" } };
|
|
577
579
|
});
|
|
578
580
|
}
|
|
579
581
|
else {
|
|
580
|
-
await func(params).catch((reason) => {
|
|
582
|
+
rs = await func(params).catch((reason) => {
|
|
581
583
|
Log_1.GLog.error(reason);
|
|
584
|
+
rs = { errcode: { id: 1008612, des: "failed" } };
|
|
582
585
|
});
|
|
583
586
|
}
|
|
584
587
|
}
|
|
585
588
|
else {
|
|
586
589
|
if (thisArg) {
|
|
587
|
-
func.call(thisArg, params);
|
|
590
|
+
rs = func.call(thisArg, params);
|
|
588
591
|
}
|
|
589
592
|
else {
|
|
590
|
-
func(params);
|
|
593
|
+
rs = func(params);
|
|
591
594
|
}
|
|
592
595
|
}
|
|
596
|
+
return rs;
|
|
593
597
|
}
|
|
594
598
|
catch (e) {
|
|
595
599
|
Log_1.GLog.error(e.stack);
|
|
600
|
+
return { errcode: { id: 1008613, des: "failed" } };
|
|
596
601
|
}
|
|
597
602
|
}
|
|
598
603
|
}
|
|
@@ -25,8 +25,8 @@ class AsyncQueueItem {
|
|
|
25
25
|
if (!funcitem.func) {
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
await cgserver_1.core.safeCall(funcitem.func, funcitem.thisArg, funcitem.params);
|
|
29
|
-
await cgserver_1.core.safeCall(funcitem.resolve);
|
|
28
|
+
let rs = await cgserver_1.core.safeCall(funcitem.func, funcitem.thisArg, funcitem.params);
|
|
29
|
+
await cgserver_1.core.safeCall(funcitem.resolve, null, rs);
|
|
30
30
|
}
|
|
31
31
|
this.running = false;
|
|
32
32
|
}
|
|
@@ -36,7 +36,8 @@ class AsyncQueueTool {
|
|
|
36
36
|
_queues;
|
|
37
37
|
async add(key, func, thisArg = null, ...params) {
|
|
38
38
|
this._queues[key] = this._queues[key] || new AsyncQueueItem(key);
|
|
39
|
-
await this._queues[key].add(func);
|
|
39
|
+
let error = await this._queues[key].add(func);
|
|
40
|
+
return error;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
exports.GAsyncQueueTool = new AsyncQueueTool();
|
package/dist/lib/Logic/Log.js
CHANGED
|
@@ -78,15 +78,18 @@ class Log {
|
|
|
78
78
|
isString(param) {
|
|
79
79
|
return typeof (param) === "string";
|
|
80
80
|
}
|
|
81
|
+
isNumber(param) {
|
|
82
|
+
return typeof (param) === "number";
|
|
83
|
+
}
|
|
81
84
|
format = function (src, formatStr) {
|
|
82
|
-
if (
|
|
85
|
+
if (exports.GLog.isString(src)) {
|
|
83
86
|
let args = Array.prototype.slice.call(arguments, 1);
|
|
84
87
|
return src.replace(/\{(\d+)\}/g, function (m, i) {
|
|
85
88
|
return args[i];
|
|
86
89
|
});
|
|
87
90
|
}
|
|
88
91
|
else {
|
|
89
|
-
if (
|
|
92
|
+
if (exports.GLog.isNumber(src)) {
|
|
90
93
|
src = new Date(src);
|
|
91
94
|
}
|
|
92
95
|
let str = formatStr;
|
|
@@ -100,5 +100,5 @@ export declare class core {
|
|
|
100
100
|
*/
|
|
101
101
|
static convertToGlobalStr(num: number): string;
|
|
102
102
|
static sleep(milliseconds: any): Promise<unknown>;
|
|
103
|
-
static safeCall(func: Function, thisArg?: any, ...params: any[]): Promise<
|
|
103
|
+
static safeCall(func: Function, thisArg?: any, ...params: any[]): Promise<any>;
|
|
104
104
|
}
|
|
@@ -15,7 +15,7 @@ declare class AsyncQueueTool {
|
|
|
15
15
|
protected _queues: {
|
|
16
16
|
[key: string]: AsyncQueueItem;
|
|
17
17
|
};
|
|
18
|
-
add(key: string, func: Function, thisArg?: any, ...params: any[]): Promise<
|
|
18
|
+
add(key: string, func: Function, thisArg?: any, ...params: any[]): Promise<unknown>;
|
|
19
19
|
}
|
|
20
20
|
export declare let GAsyncQueueTool: AsyncQueueTool;
|
|
21
21
|
export {};
|