mm_expand 2.3.3 → 2.3.5

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/array.js CHANGED
@@ -48,7 +48,7 @@ function toList(list, sub = 'sub', result = []) {
48
48
 
49
49
 
50
50
  /**
51
- * @description 排序
51
+ * 排序
52
52
  * @param {string} key 属性键
53
53
  * @returns {Function(Object, Object)} 排序函数
54
54
  */
@@ -56,9 +56,9 @@ function newSort(key) {
56
56
  var field = key;
57
57
  return {
58
58
  asc: createAscSort(field),
59
- ascCn: createAscCnSort(field),
59
+ asc_cn: createAscCnSort(field),
60
60
  desc: createDescSort(field),
61
- descCn: createDescCnSort(field)
61
+ desc_cn: createDescCnSort(field)
62
62
  };
63
63
  }
64
64
 
@@ -155,7 +155,7 @@ function createDescCnSort(field) {
155
155
  /**
156
156
  * 列表转树形列表
157
157
  * @param {string | object} idOrConfig 主键字段名或配置对象
158
- * @param id_or_config
158
+ * @param id_or_config
159
159
  * @param {number} value 根节点值
160
160
  * @param {string} father_id 父节点字段名
161
161
  * @param {string} sub 子节点字段名
@@ -185,7 +185,7 @@ Array.prototype.toList = function (sub = 'sub', arr = []) {
185
185
  };
186
186
 
187
187
  /**
188
- * @description 拷贝数组
188
+ * 拷贝数组
189
189
  * @param {boolean} has 是否非空拷贝,如果含有数据才拷贝,不含数据不拷贝
190
190
  * @returns {Array} 新数组
191
191
  */
@@ -208,7 +208,7 @@ Array.prototype.copy = function (has) {
208
208
  return result;
209
209
  };
210
210
  /**
211
- * @description 遍历数组执行函数
211
+ * 遍历数组执行函数
212
212
  * @param {Function(Object):Boolean} func 处理函数
213
213
  */
214
214
  Array.prototype.func = function (func) {
@@ -220,9 +220,9 @@ Array.prototype.func = function (func) {
220
220
  }
221
221
  };
222
222
  /**
223
- * @description 数组转字符串
223
+ * 数组转字符串
224
224
  * @param {string} splitStr 分隔符
225
- * @param split_str
225
+ * @param split_str
226
226
  * @param {string} key 对象属性名
227
227
  * @returns {string} 字符串
228
228
  */
@@ -246,7 +246,7 @@ Array.prototype.toStr = function (split_str, key) {
246
246
  return result.replace(split_str, '');
247
247
  };
248
248
  /**
249
- * @description 清空数组
249
+ * 清空数组
250
250
  * @returns {Array} 清空的数组
251
251
  */
252
252
  Array.prototype.clear = function () {
@@ -254,7 +254,7 @@ Array.prototype.clear = function () {
254
254
  return this;
255
255
  };
256
256
  /**
257
- * @description 修改数组成员
257
+ * 修改数组成员
258
258
  * @param {object} query 搜索条件
259
259
  * @param {object} replacement 替换对象
260
260
  * @returns {Array} 修改后的数组
@@ -270,7 +270,7 @@ Array.prototype.set = function (query, replacement) {
270
270
  return this;
271
271
  };
272
272
  /**
273
- * @description 对象列表排序
273
+ * 对象列表排序
274
274
  * @param {string} method = [asc|desc] 排序方式, asc升序, desc降序
275
275
  * @param {string} key 用来判断排序的对象属性
276
276
  * @returns {Array} 列表自身
@@ -313,7 +313,7 @@ Array.prototype._sortByValue = function (method) {
313
313
  * 获取属性排序函数
314
314
  * @param {string} method 排序方式
315
315
  * @param {boolean} isStr 是否为字符串
316
- * @param is_str
316
+ * @param is_str
317
317
  * @param {object} cs 排序对象
318
318
  * @returns {Function} 排序函数
319
319
  */
@@ -331,7 +331,7 @@ Array.prototype._getSortFunc = function (method, is_str, cs) {
331
331
  * 获取值排序函数
332
332
  * @param {string} method 排序方式
333
333
  * @param {boolean} isStr 是否为字符串
334
- * @param is_str
334
+ * @param is_str
335
335
  * @returns {Function} 排序函数
336
336
  */
337
337
  Array.prototype._getValueSortFunc = function (method, is_str) {
@@ -384,7 +384,7 @@ Array.prototype._ascNumSort = function (a, b) {
384
384
  return a - b;
385
385
  };
386
386
  /**
387
- * @description 数组列表取数组
387
+ * 数组列表取数组
388
388
  * @param {string} key 取的属性
389
389
  * @returns {Array} 截取的数组
390
390
  */
@@ -400,7 +400,7 @@ Array.prototype.toArr = function (key) {
400
400
  };
401
401
 
402
402
  /**
403
- * @description 从数组获取对象
403
+ * 从数组获取对象
404
404
  * @param {object} query 查询条件
405
405
  * @param {boolean} single 是否只返回第一个
406
406
  * @returns {object | Array} 对象或对象数组
@@ -441,7 +441,7 @@ Array.prototype.get = function (query, single) {
441
441
  */
442
442
 
443
443
  /**
444
- * @description 从数组获取对象
444
+ * 从数组获取对象
445
445
  * @param {object} query 查询条件
446
446
  * @returns {object} 对象
447
447
  */
@@ -460,7 +460,7 @@ Array.prototype.getObj = function (query) {
460
460
  return result;
461
461
  };
462
462
  /**
463
- * @description 获取数组对象的属性值
463
+ * 获取数组对象的属性值
464
464
  * @param {string} key 属性名
465
465
  * @param {object} query 查询条件
466
466
  * @returns {object} 属性值
@@ -474,7 +474,7 @@ Array.prototype.getVal = function (key, query) {
474
474
  }
475
475
  };
476
476
  /**
477
- * @description 获取符合条件的数组对象
477
+ * 获取符合条件的数组对象
478
478
  * @param {object} query 查询条件
479
479
  * @returns {Array} 对象数组
480
480
  */
@@ -494,7 +494,7 @@ Array.prototype.getList = function (query) {
494
494
  return results;
495
495
  };
496
496
  /**
497
- * @description 获取数组所有对象的属性值
497
+ * 获取数组所有对象的属性值
498
498
  * @param {string} key 属性名
499
499
  * @param {object} query 查询条件
500
500
  * @returns {Array} 属性值数组
@@ -518,7 +518,7 @@ Array.prototype.getArr = function (key, query) {
518
518
  return values;
519
519
  };
520
520
  /**
521
- * @description 给数组对象添加属性值
521
+ * 给数组对象添加属性值
522
522
  * @param {string} key 属性名
523
523
  * @param {object} value 属性值
524
524
  * @param {object} query 查询条件
@@ -578,7 +578,7 @@ Array.prototype._addValWithoutQuery = function (key, value, single, len) {
578
578
  }
579
579
  };
580
580
  /**
581
- * @description 给数组添加对象
581
+ * 给数组添加对象
582
582
  * @param {object} item 对象
583
583
  * @param {object} query 查询条件
584
584
  * @returns {Array} 对象数组
@@ -608,7 +608,7 @@ Array.prototype.addObj = function (item, query) {
608
608
  };
609
609
 
610
610
  /**
611
- * @description 给数组添加多个对象
611
+ * 给数组添加多个对象
612
612
  * @param {Array} items 数组
613
613
  * @param {object} query 查询条件
614
614
  * @returns {Array} 对象数组
@@ -621,7 +621,7 @@ Array.prototype.addList = function (items, query) {
621
621
  return this;
622
622
  };
623
623
  /**
624
- * @description 给数组添加一个对象或列表
624
+ * 给数组添加一个对象或列表
625
625
  * @param {object | Array} value 对象或数组
626
626
  * @param {object} query 查询条件
627
627
  * @returns {Array} 对象数组
@@ -635,7 +635,7 @@ Array.prototype.add = function (value, query) {
635
635
  return this;
636
636
  };
637
637
  /**
638
- * @description 删除数组中对象的属性
638
+ * 删除数组中对象的属性
639
639
  * @param {string} key 对象属性键
640
640
  * @param {object} query 查询条件
641
641
  * @param {boolean} single 是否只删除第一个符合条件的对象
@@ -674,7 +674,7 @@ Array.prototype.delVal = function (key, query, single) {
674
674
  };
675
675
 
676
676
  /**
677
- * @description 删除数组中的对象
677
+ * 删除数组中的对象
678
678
  * @param {object} query 查询条件
679
679
  * @param {boolean} single 是否只删除第一个符合条件的对象
680
680
  * @returns {Array} 对象数组
@@ -711,7 +711,7 @@ Array.prototype.del = function (query, single) {
711
711
  return this;
712
712
  };
713
713
  /**
714
- * @description 删除多个不同的数组成员
714
+ * 删除多个不同的数组成员
715
715
  * @param {Array} list 查询条件列表
716
716
  * @param {boolean} end 是否中断循环,中断只删除第一个符合条件的对象
717
717
  * @returns {Array} 对象数组
@@ -724,7 +724,7 @@ Array.prototype.delList = function (list, end) {
724
724
  return this;
725
725
  };
726
726
  /**
727
- * @description 设置数组中对象的属性值
727
+ * 设置数组中对象的属性值
728
728
  * @param {string} key 属性键
729
729
  * @param {object} value 属性值
730
730
  * @param {object} query 查询条件
@@ -753,7 +753,7 @@ Array.prototype.setVal = function (key, value, query, single) {
753
753
  return this;
754
754
  };
755
755
  /**
756
- * @description 设置数组中对象的属性值
756
+ * 设置数组中对象的属性值
757
757
  * @param {object} replacement 对象
758
758
  * @param {object} query 查询条件
759
759
  * @param {boolean} end 是否中断循环,中断只修改第一个符合条件的对象
@@ -775,7 +775,7 @@ Array.prototype.setObj = function (replacement, query, end) {
775
775
  return this;
776
776
  };
777
777
  /**
778
- * @description 设置数组中对象的属性值
778
+ * 设置数组中对象的属性值
779
779
  * @param {Array} items 对象列表
780
780
  * @param {object} key 对象主键
781
781
  * @param {boolean} end 是否中断循环,中断只修改第一个符合条件的对象
@@ -794,7 +794,7 @@ Array.prototype.setList = function (items, key, end) {
794
794
  }
795
795
  };
796
796
  /**
797
- * @description 搜索符合条件的成员
797
+ * 搜索符合条件的成员
798
798
  * @param {string} keyword 搜索关键词
799
799
  * @param {string} key 主键, 用于列表数组时
800
800
  * @returns {Array} 返回符合条件的结果
@@ -933,7 +933,7 @@ Array.prototype._createExactFunc = function (key, term, results) {
933
933
  }
934
934
  };
935
935
  /**
936
- * @description 判断是否包含成员
936
+ * 判断是否包含成员
937
937
  * @param {object} query 查询条件
938
938
  * @returns {boolean} 有则返回true,没有则返回false
939
939
  */
@@ -950,7 +950,7 @@ Array.prototype.has = function (query) {
950
950
  };
951
951
 
952
952
  /**
953
- * @description 取含匹配项
953
+ * 取含匹配项
954
954
  * @param {string} str 被匹配的字符串
955
955
  * @param {string} key 用于对象列表时查询
956
956
  * @returns {object} 返回匹配的第一项
@@ -977,13 +977,13 @@ Array.prototype.getMatch = function (str, key) {
977
977
  };
978
978
 
979
979
  /**
980
- * @description 数组转对象
980
+ * 数组转对象
981
981
  * @param {string} key 主键, 用作对象索引
982
982
  * @returns {object} 对象
983
983
  */
984
984
  Array.prototype.toObj = function (key) {
985
985
  var result = {};
986
- this.map(function (item) {
986
+ this.map((item) => {
987
987
  var name = item[key];
988
988
  if (name) {
989
989
  result[name] = item;
@@ -1000,8 +1000,8 @@ Array.prototype.to2D = function (size) {
1000
1000
  var arr = this;
1001
1001
  let new_arr = [];
1002
1002
  for (let i = 0; i < arr.length; i += size) {
1003
- let array_chunk = arr.slice(i, i + size);
1004
- new_arr.push(array_chunk);
1003
+ let chunk = arr.slice(i, i + size);
1004
+ new_arr.push(chunk);
1005
1005
  }
1006
1006
  return new_arr;
1007
1007
  };
package/lib/base.js CHANGED
@@ -131,7 +131,7 @@ Base.prototype.setConfig = function (config) {
131
131
 
132
132
  /**
133
133
  * 获取当前配置
134
- * @returns {Object} 配置对象
134
+ * @returns {object} 配置对象
135
135
  */
136
136
  Base.prototype.getConfig = function () {
137
137
  return this.config;
@@ -318,7 +318,7 @@ Base.prototype._doMainMethod = async function (method, ctx) {
318
318
  */
319
319
  Base.prototype._doRenderPhase = async function (method, ctx) {
320
320
  if (ctx.result && !ctx.error) {
321
- let result = await this.emitWaterfall(method + ':render', ctx.result, ctx);
321
+ let result = await this.emitWate(method + ':render', ctx.result, ctx);
322
322
  if (result) {
323
323
  ctx.result = result;
324
324
  }
@@ -394,10 +394,10 @@ Base.prototype.doSmart = async function (method, ...params) {
394
394
  }
395
395
 
396
396
  // 检查是否有监听器
397
- const has_listeners = this._hasEventListeners(method);
397
+ let has_list = this._hasEventListeners(method);
398
398
 
399
399
  // 根据选项和监听器情况选择执行方式
400
- if (options.fast || !has_listeners) {
400
+ if (options.fast || !has_list) {
401
401
  // 快速执行:无监听器或明确要求快速
402
402
  return await this.doEasy(method, ...params);
403
403
  } else {
@@ -513,7 +513,7 @@ Base.prototype._cmdParseCommand = function (ctx) {
513
513
  */
514
514
  Base.prototype._cmdTraversePath = async function (ctx) {
515
515
  for (let index = 0; index < ctx.cmds.length; index++) {
516
- const key = ctx.cmds[index];
516
+ let key = ctx.cmds[index];
517
517
 
518
518
  if (!key || key.trim() === '') {
519
519
  this.log('error', `指令包含空键名 [${ctx.command}]`);
@@ -532,8 +532,8 @@ Base.prototype._cmdTraversePath = async function (ctx) {
532
532
  ctx.obj = ctx.obj[key];
533
533
 
534
534
  // 检查当前对象类型并处理
535
- const is_last = index === ctx.cmds.length - 1;
536
- const should_stop = await this._cmdHandleType(ctx, key, is_last);
535
+ let is_last = index === ctx.cmds.length - 1;
536
+ let should_stop = await this._cmdHandleType(ctx, key, is_last);
537
537
 
538
538
  if (should_stop || ctx.error) {
539
539
  return;
@@ -553,14 +553,14 @@ Base.prototype._cmdTraversePath = async function (ctx) {
553
553
  * @private
554
554
  */
555
555
  Base.prototype._cmdHandleType = async function (ctx, key, is_last) {
556
- const type = typeof ctx.obj;
556
+ let type = typeof ctx.obj;
557
557
 
558
558
  if (type === 'function') {
559
559
  return await this._cmdHandleFunction(ctx, is_last);
560
560
  } else if (Array.isArray(ctx.obj)) {
561
561
  return this._cmdHandleArray(ctx, is_last);
562
562
  } else if (type !== 'object' || ctx.obj === null) {
563
- return this._cmdHandlePrimitive(ctx, is_last);
563
+ return this._cmdHandlePrim(ctx, is_last);
564
564
  }
565
565
 
566
566
  // 对象类型,继续遍历
@@ -775,10 +775,10 @@ Base.prototype._helpProcessArray = function (array) {
775
775
  Base.prototype._helpProcessObject = function (obj) {
776
776
  let result = '';
777
777
 
778
- for (const key in obj) {
778
+ for (let key in obj) {
779
779
  try {
780
780
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
781
- const value = obj[key];
781
+ let value = obj[key];
782
782
  if (Array.isArray(value)) {
783
783
  result += '.' + key + ' array\r\n';
784
784
  } else {
@@ -805,8 +805,8 @@ Base.prototype._helpUsingObject = async function (ctx) {
805
805
  this.log('warn', 'help参数为空或无效,将显示当前对象信息');
806
806
  ctx.result = this._helpProcessObject(this);
807
807
  } else {
808
- const target = this._helpNavigatePath(ctx.param);
809
- ctx.result = this._helpFormatResult(target);
808
+ let target = this._helpNavigatePath(ctx.param);
809
+ ctx.result = this._helpFormat(target);
810
810
  }
811
811
  } catch (error) {
812
812
  this.log('error', '对象遍历失败', error);
@@ -821,11 +821,11 @@ Base.prototype._helpUsingObject = async function (ctx) {
821
821
  * @private
822
822
  */
823
823
  Base.prototype._helpNavigatePath = function (path) {
824
- const keys = path.split('.');
824
+ let keys = path.split('.');
825
825
  let obj = this;
826
826
 
827
827
  for (let i = 0; i < keys.length; i++) {
828
- const key = keys[i];
828
+ let key = keys[i];
829
829
 
830
830
  if (!key || key.trim() === '') {
831
831
  this.log('warn', `路径包含空键名,在位置${i}处停止`);
package/lib/date.js CHANGED
@@ -1,9 +1,10 @@
1
1
  /**
2
- * @description 时间格式化
2
+ * 时间格式化
3
3
  * @param {string} format 指定格式
4
4
  * @returns {string} 时间格式字符串
5
5
  */
6
- Date.prototype.toStr = function (format) {
6
+ Date.prototype.toStr = function (fm) {
7
+ var format = fm;
7
8
  var t = this;
8
9
  if (format.endsWith('Z')) {
9
10
  t = t.addSeconds(-28800);
@@ -24,7 +25,7 @@ Date.prototype.toStr = function (format) {
24
25
  for (var k in obj) {
25
26
  if (new RegExp('(' + k + ')').test(format)) {
26
27
  var x = RegExp.$1;
27
- format = format.replace(x, x.length == 1 ? obj[k] : ('00' + obj[k]).substring(('' +
28
+ format = format.replace(x, x.length == 1 ? obj[k] : ('00' + obj[k]).substring(('' +
28
29
  obj[k]).length));
29
30
  }
30
31
  }
@@ -32,7 +33,7 @@ Date.prototype.toStr = function (format) {
32
33
  };
33
34
 
34
35
  /**
35
- * @description 获取当前时间戳
36
+ * 获取当前时间戳
36
37
  * @returns {number} 返回时间戳
37
38
  */
38
39
  Date.prototype.stamp = function () {
@@ -41,7 +42,7 @@ Date.prototype.stamp = function () {
41
42
  };
42
43
 
43
44
  /**
44
- * @description 计算时间差(时间间隔)
45
+ * 计算时间差(时间间隔)
45
46
  * @param {string | Date} end 结束时间
46
47
  * @param {string} unit 时间单位 [day|hours|minutes]
47
48
  * @returns {number} 间隔时长
@@ -63,7 +64,7 @@ Date.prototype.interval = function (end, unit) {
63
64
  };
64
65
 
65
66
  /**
66
- * @description 时间添加天数
67
+ * 时间添加天数
67
68
  * @param {number} days 天数
68
69
  * @returns {Date} 时间对象
69
70
  */
@@ -73,7 +74,7 @@ Date.prototype.addDays = function (days) {
73
74
  };
74
75
 
75
76
  /**
76
- * @description 时间添加秒数
77
+ * 时间添加秒数
77
78
  * @param {number} seconds 秒数
78
79
  * @returns {Date} 时间对象
79
80
  */
@@ -83,7 +84,7 @@ Date.prototype.addSeconds = function (seconds) {
83
84
  };
84
85
 
85
86
  /**
86
- * @description 导出Date原型扩展
87
+ * 导出Date原型扩展
87
88
  */
88
89
  module.exports = {
89
90
  Date