mm_expand 2.4.2 → 2.4.4
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/lib/base.js +3 -3
- package/lib/errors.js +1 -1
- package/lib/event.js +7 -7
- package/lib/eventer.js +2294 -2422
- package/lib/file.js +797 -797
- package/lib/global.js +2 -1
- package/lib/lang.js +6 -6
- package/lib/logger.js +2 -2
- package/lib/string.js +11 -10
- package/package.json +2 -2
package/lib/base.js
CHANGED
|
@@ -300,7 +300,7 @@ Base.prototype._doCheckPhase = async function (method, ctx) {
|
|
|
300
300
|
Base.prototype._doMainMethod = async function (method, ctx) {
|
|
301
301
|
if (!ctx.result) {
|
|
302
302
|
// 触发启动中事件
|
|
303
|
-
result = await this.emitWait(`${method}:main`, ctx);
|
|
303
|
+
let result = await this.emitWait(`${method}:main`, ctx);
|
|
304
304
|
if (result) {
|
|
305
305
|
ctx.result = result;
|
|
306
306
|
}
|
|
@@ -562,7 +562,7 @@ Base.prototype._cmdHandleType = async function (ctx, key, is_last) {
|
|
|
562
562
|
} else if (Array.isArray(ctx.obj)) {
|
|
563
563
|
return this._cmdHandleArray(ctx, is_last);
|
|
564
564
|
} else if (type !== 'object' || ctx.obj === null) {
|
|
565
|
-
return this.
|
|
565
|
+
return this._cmdHandlePrimitive(ctx, is_last);
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
// 对象类型,继续遍历
|
|
@@ -808,7 +808,7 @@ Base.prototype._helpUsingObject = async function (ctx) {
|
|
|
808
808
|
ctx.result = this._helpProcessObject(this);
|
|
809
809
|
} else {
|
|
810
810
|
let target = this._helpNavigatePath(ctx.param);
|
|
811
|
-
ctx.result = this.
|
|
811
|
+
ctx.result = this._helpFormatResult(target);
|
|
812
812
|
}
|
|
813
813
|
} catch (error) {
|
|
814
814
|
this.log('error', '对象遍历失败', error);
|
package/lib/errors.js
CHANGED
|
@@ -129,7 +129,7 @@ Errors.prototype.get = function (code) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// 如果当前语言包没有,尝试英文包
|
|
132
|
-
if (lang !== 'en-US' && this._langs['en-US'][code]) {
|
|
132
|
+
if (lang !== 'en-US' && this._langs['en-US'] && this._langs['en-US'][code]) {
|
|
133
133
|
return this._langs['en-US'][code];
|
|
134
134
|
}
|
|
135
135
|
|
package/lib/event.js
CHANGED
|
@@ -122,8 +122,8 @@ class Event {
|
|
|
122
122
|
let listeners = store.map.get(event_name);
|
|
123
123
|
|
|
124
124
|
// 检查监听器数量限制
|
|
125
|
-
if (listeners.length >= this.#event_config.
|
|
126
|
-
this.#logger.warn(`事件 ${event_name} 的监听器数量已达到上限 ${this.#event_config.
|
|
125
|
+
if (listeners.length >= this.#event_config.max_list) {
|
|
126
|
+
this.#logger.warn(`事件 ${event_name} 的监听器数量已达到上限 ${this.#event_config.max_list}`);
|
|
127
127
|
return this;
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -146,7 +146,7 @@ class Event {
|
|
|
146
146
|
* @returns {Event} 返回this,支持链式调用
|
|
147
147
|
*/
|
|
148
148
|
once(event_name, listener) {
|
|
149
|
-
once_wrapper = (...args) => {
|
|
149
|
+
let once_wrapper = (...args) => {
|
|
150
150
|
this.off(event_name, once_wrapper);
|
|
151
151
|
return listener(...args);
|
|
152
152
|
};
|
|
@@ -473,8 +473,8 @@ class Event {
|
|
|
473
473
|
let listeners = store.map.get(event_name);
|
|
474
474
|
|
|
475
475
|
// 检查监听器数量限制
|
|
476
|
-
if (listeners.length >= this.#event_config.
|
|
477
|
-
this.#logger.warn(`事件 ${event_name} 的监听器数量已达到上限 ${this.#event_config.
|
|
476
|
+
if (listeners.length >= this.#event_config.max_list) {
|
|
477
|
+
this.#logger.warn(`事件 ${event_name} 的监听器数量已达到上限 ${this.#event_config.max_list}`);
|
|
478
478
|
return this;
|
|
479
479
|
}
|
|
480
480
|
|
|
@@ -498,7 +498,7 @@ class Event {
|
|
|
498
498
|
* @returns {Event} 返回this,支持链式调用
|
|
499
499
|
*/
|
|
500
500
|
prependOnceListener(event_name, listener) {
|
|
501
|
-
once_wrapper = (...args) => {
|
|
501
|
+
let once_wrapper = (...args) => {
|
|
502
502
|
this.off(event_name, once_wrapper);
|
|
503
503
|
return listener(...args);
|
|
504
504
|
};
|
|
@@ -586,7 +586,7 @@ class Event {
|
|
|
586
586
|
*/
|
|
587
587
|
log(level, message, ...params) {
|
|
588
588
|
this.getLogger()[level](`[${this.constructor.name}] ${message}`, ...params);
|
|
589
|
-
}
|
|
589
|
+
}
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
module.exports = {
|