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/global.js CHANGED
@@ -21,6 +21,7 @@ function sleep(milli_seconds, obj, key) {
21
21
 
22
22
  if (!obj) {
23
23
  simpleSleep(end_time);
24
+ return;
24
25
  }
25
26
 
26
27
  if (key) {
@@ -278,7 +279,7 @@ if (!global.$) {
278
279
  }
279
280
 
280
281
  // 先判断基本类型
281
- compareBasic(source, target);
282
+ var basic_result = compareBasic(source, target);
282
283
  if (basic_result !== null) {
283
284
  return basic_result;
284
285
  }
package/lib/lang.js CHANGED
@@ -6,7 +6,7 @@ const { Base } = require('./base.js');
6
6
  */
7
7
  class Lang extends Base {
8
8
  static config = {
9
- zhCn: {},
9
+ zh_cn: {},
10
10
  en: {},
11
11
  default: 'zh_cn',
12
12
  fallback: true
@@ -27,7 +27,7 @@ class Lang extends Base {
27
27
  en(count) {
28
28
  return count === 1 ? 0 : 1;
29
29
  },
30
- zhCn() {
30
+ zh_cn(count) {
31
31
  return 0;
32
32
  }
33
33
  };
@@ -345,8 +345,8 @@ Lang.prototype.formatDate = function (dt, format = 'YYYY-MM-DD hh:mm:ss') {
345
345
  * @param {number} num - 要格式化的数字
346
346
  * @param {object} [options] - 选项
347
347
  * @param {number} [options.decimals=2] - 小数位数
348
- * @param {string} [options.decimalSeparator] - 小数分隔符
349
- * @param {string} [options.thousandsSeparator] - 千位分隔符
348
+ * @param {string} [options.decimal_separator] - 小数分隔符
349
+ * @param {string} [options.thousands_separator] - 千位分隔符
350
350
  * @returns {string} 格式化后的数字字符串
351
351
  */
352
352
  Lang.prototype.formatNumber = function (num, options = {}) {
@@ -359,8 +359,8 @@ Lang.prototype.formatNumber = function (num, options = {}) {
359
359
  var decimals = typeof opt.decimals === 'number' ? opt.decimals : 2;
360
360
 
361
361
  // 获取语言特定的分隔符
362
- var decimal_sepa = opt.decimalSeparator || '.';
363
- var thou_sepa = opt.thousandsSeparator || ',';
362
+ var decimal_sepa = opt.decimal_separator || '.';
363
+ var thou_sepa = opt.thousands_separator || ',';
364
364
 
365
365
  // 格式化数字
366
366
  var parts = num.toFixed(decimals).split('.');
package/lib/logger.js CHANGED
@@ -67,7 +67,7 @@ Logger.prototype.debug = function (message, ...args) {
67
67
  this.emit('debug:after', ctx);
68
68
  } catch (error) {
69
69
  // 日志错误处理
70
- this._logger.error(error);
70
+ this.getLogger().error(error);
71
71
  }
72
72
  };
73
73
 
@@ -130,7 +130,7 @@ Logger.prototype.warn = function (message, ...args) {
130
130
  this.emit('warn:after', ctx);
131
131
  } catch (error) {
132
132
  // 日志错误处理
133
- this._logger.error(error);
133
+ this.getLogger().error(error);
134
134
  }
135
135
  };
136
136
 
package/lib/string.js CHANGED
@@ -4,6 +4,7 @@
4
4
  const json5 = require('json5');
5
5
  const pinyin = require('pinyinlite');
6
6
  const { createHash, createCipheriv, createDecipheriv } = require('crypto');
7
+ const { XMLParser } = require('fast-xml-parser');
7
8
 
8
9
  /**
9
10
  * form-data转对象
@@ -57,7 +58,7 @@ String.prototype.aesEncode = function (key, iv) {
57
58
  chunks.push(cipher.final(encoding));
58
59
  return chunks.join('');
59
60
  } catch (error) {
60
- throw new Error('AES加密错误:', error);
61
+ throw new Error('AES加密错误: ' + error.message);
61
62
  }
62
63
  };
63
64
 
@@ -83,7 +84,7 @@ String.prototype.aesDecode = function (key, iv) {
83
84
  chunks.push(decipher.final(encoding));
84
85
  return chunks.join('');
85
86
  } catch (error) {
86
- throw new Error('AES解密错误:', error);
87
+ throw new Error('AES解密错误: ' + error.message);
87
88
  }
88
89
  };
89
90
 
@@ -123,7 +124,7 @@ String.prototype.toJson = function () {
123
124
  try {
124
125
  return json5.parse(this);
125
126
  } catch (error) {
126
- throw new Error('json反序列化错误', error);
127
+ throw new Error('json反序列化错误: ' + error.message);
127
128
  }
128
129
  };
129
130
  /**
@@ -132,10 +133,10 @@ String.prototype.toJson = function () {
132
133
  */
133
134
  String.prototype.toXml = function () {
134
135
  try {
135
- const parser = new XmlParser();
136
+ const parser = new XMLParser();
136
137
  return parser.parse(this);
137
138
  } catch (error) {
138
- throw new Error('xml反序列化错误!', error);
139
+ throw new Error('xml反序列化错误: ' + error.message);
139
140
  }
140
141
  };
141
142
  /**
@@ -385,8 +386,8 @@ String.prototype.addSeconds = function (seconds, format) {
385
386
  }
386
387
 
387
388
  // 降级处理
388
- const newTime = new Date(date.getTime() + seconds * 1000);
389
- return format ? newTime.toISOString() : newTime;
389
+ const new_time = new Date(date.getTime() + seconds * 1000);
390
+ return format ? new_time.toISOString() : new_time;
390
391
  };
391
392
 
392
393
  /**
@@ -409,8 +410,8 @@ String.prototype.addDays = function (days, format) {
409
410
  }
410
411
 
411
412
  // 降级处理
412
- const newTime = new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
413
- return format ? newTime.toISOString() : newTime;
413
+ const new_time = new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
414
+ return format ? new_time.toISOString() : new_time;
414
415
  };
415
416
 
416
417
  /**
@@ -480,7 +481,7 @@ String.prototype.toRx = function (mode) {
480
481
  let pattern = this.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
481
482
  return new RegExp(pattern, _mode);
482
483
  } catch (error) {
483
- throw new Error('字符串转正则错误:', error);
484
+ throw new Error('字符串转正则错误: ' + error.message);
484
485
  }
485
486
  };
486
487
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_expand",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "超级美眉原型函数扩展模块 - 增强的字符串、数组、对象、日期操作,具备错误预防功能并简化业务逻辑",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "eslint": "^10.6.0",
49
- "eslint-plugin-jsdoc": "^63.0.10",
49
+ "eslint-plugin-jsdoc": "^63.0.12",
50
50
  "mm_eslint": "^1.7.5"
51
51
  },
52
52
  "engines": {