util-helpers 4.16.2 → 4.17.0

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.
Files changed (259) hide show
  1. package/dist/util-helpers.js +1542 -4040
  2. package/dist/util-helpers.js.map +1 -1
  3. package/dist/util-helpers.min.js +1 -1
  4. package/dist/util-helpers.min.js.map +1 -1
  5. package/esm/ajax.js +50 -146
  6. package/esm/blobToDataURL.js +4 -34
  7. package/esm/bytesToSize.js +12 -37
  8. package/esm/calculateCursorPosition.js +30 -52
  9. package/esm/dataURLToBlob.js +14 -28
  10. package/esm/divide.js +24 -48
  11. package/esm/download.js +83 -164
  12. package/esm/fileReader.js +18 -64
  13. package/esm/filterTree.js +25 -55
  14. package/esm/findTreeNode.js +39 -67
  15. package/esm/findTreeNodes.js +35 -66
  16. package/esm/findTreeSelect.js +38 -74
  17. package/esm/formatBankCard.js +13 -43
  18. package/esm/formatMobile.js +17 -43
  19. package/esm/formatMoney.js +59 -139
  20. package/esm/index.js +55 -130
  21. package/esm/isBankCard.js +22 -57
  22. package/esm/isBusinessLicense.js +32 -78
  23. package/esm/isChinese.js +23 -66
  24. package/esm/isEmail.js +6 -21
  25. package/esm/isHMCard.js +5 -28
  26. package/esm/isIPv4.js +5 -22
  27. package/esm/isIPv6.js +5 -36
  28. package/esm/isIdCard.js +27 -66
  29. package/esm/isMobile.js +5 -20
  30. package/esm/isPassport.js +5 -22
  31. package/esm/isPassword.js +7 -48
  32. package/esm/isPostcode.js +5 -20
  33. package/esm/isPromiseLike.js +3 -18
  34. package/esm/isQQ.js +5 -20
  35. package/esm/isSocialCreditCode.js +28 -83
  36. package/esm/isSwiftCode.js +6 -25
  37. package/esm/isTWCard.js +11 -37
  38. package/esm/isTelephone.js +6 -27
  39. package/esm/isUrl.js +5 -44
  40. package/esm/isVehicle.js +5 -28
  41. package/esm/isWX.js +5 -20
  42. package/esm/listToTree.js +51 -120
  43. package/esm/minus.js +21 -39
  44. package/esm/normalizeString.js +8 -29
  45. package/esm/numberToChinese.js +96 -215
  46. package/esm/padZero.js +14 -36
  47. package/esm/parseIdCard.js +64 -129
  48. package/esm/plus.js +21 -39
  49. package/esm/randomString.js +13 -45
  50. package/esm/replaceChar.js +27 -77
  51. package/esm/round.js +14 -31
  52. package/esm/safeDate.js +12 -55
  53. package/esm/setDataURLPrefix.js +6 -29
  54. package/esm/strlen.js +14 -30
  55. package/esm/times.js +24 -42
  56. package/esm/transformFieldNames.js +37 -93
  57. package/esm/treeToList.js +25 -84
  58. package/esm/utils/config.js +4 -14
  59. package/esm/utils/constants.js +4 -4
  60. package/esm/utils/convertToString.js +4 -9
  61. package/esm/utils/devWarn.js +11 -11
  62. package/esm/utils/math.util.js +95 -181
  63. package/esm/utils/type/isBlob.js +4 -24
  64. package/esm/utils/type/isNaN.js +4 -19
  65. package/esm/utils/type/isNil.js +5 -13
  66. package/esm/utils/type/isNull.js +3 -18
  67. package/esm/utils/type/isNumber.js +4 -28
  68. package/esm/utils/type/isObject.js +4 -23
  69. package/esm/utils/type/isString.js +4 -19
  70. package/esm/utils/type/isSymbol.js +4 -19
  71. package/esm/utils/type/isType.js +3 -12
  72. package/esm/utils/type/isUndefined.js +3 -21
  73. package/esm/validatePassword.js +86 -237
  74. package/esm/waitTime.js +7 -26
  75. package/lib/ajax.js +51 -152
  76. package/lib/blobToDataURL.js +5 -40
  77. package/lib/bytesToSize.js +13 -43
  78. package/lib/calculateCursorPosition.js +32 -58
  79. package/lib/dataURLToBlob.js +15 -34
  80. package/lib/divide.js +26 -60
  81. package/lib/download.js +85 -169
  82. package/lib/fileReader.js +19 -70
  83. package/lib/filterTree.js +27 -66
  84. package/lib/findTreeNode.js +40 -77
  85. package/lib/findTreeNodes.js +36 -76
  86. package/lib/findTreeSelect.js +40 -82
  87. package/lib/formatBankCard.js +15 -50
  88. package/lib/formatMobile.js +19 -50
  89. package/lib/formatMoney.js +60 -150
  90. package/lib/index.js +117 -395
  91. package/lib/isBankCard.js +24 -64
  92. package/lib/isBusinessLicense.js +34 -85
  93. package/lib/isChinese.js +24 -73
  94. package/lib/isEmail.js +7 -27
  95. package/lib/isHMCard.js +7 -35
  96. package/lib/isIPv4.js +7 -29
  97. package/lib/isIPv6.js +7 -43
  98. package/lib/isIdCard.js +29 -73
  99. package/lib/isMobile.js +7 -27
  100. package/lib/isPassport.js +7 -29
  101. package/lib/isPassword.js +9 -55
  102. package/lib/isPostcode.js +7 -27
  103. package/lib/isPromiseLike.js +4 -24
  104. package/lib/isQQ.js +7 -27
  105. package/lib/isSocialCreditCode.js +30 -90
  106. package/lib/isSwiftCode.js +7 -32
  107. package/lib/isTWCard.js +13 -44
  108. package/lib/isTelephone.js +7 -33
  109. package/lib/isUrl.js +6 -49
  110. package/lib/isVehicle.js +7 -35
  111. package/lib/isWX.js +7 -27
  112. package/lib/listToTree.js +53 -131
  113. package/lib/minus.js +23 -51
  114. package/lib/normalizeString.js +10 -36
  115. package/lib/numberToChinese.js +98 -222
  116. package/lib/padZero.js +16 -43
  117. package/lib/parseIdCard.js +65 -138
  118. package/lib/plus.js +23 -51
  119. package/lib/randomString.js +14 -51
  120. package/lib/replaceChar.js +28 -83
  121. package/lib/round.js +15 -37
  122. package/lib/safeDate.js +13 -63
  123. package/lib/setDataURLPrefix.js +7 -35
  124. package/lib/strlen.js +16 -37
  125. package/lib/times.js +26 -53
  126. package/lib/transformFieldNames.js +38 -101
  127. package/lib/treeToList.js +27 -94
  128. package/lib/utils/config.js +6 -23
  129. package/lib/utils/constants.js +3 -11
  130. package/lib/utils/convertToString.js +6 -16
  131. package/lib/utils/devWarn.js +13 -17
  132. package/lib/utils/math.util.js +95 -185
  133. package/lib/utils/type/isBlob.js +6 -31
  134. package/lib/utils/type/isNaN.js +6 -26
  135. package/lib/utils/type/isNil.js +7 -20
  136. package/lib/utils/type/isNull.js +4 -24
  137. package/lib/utils/type/isNumber.js +6 -35
  138. package/lib/utils/type/isObject.js +5 -29
  139. package/lib/utils/type/isString.js +6 -26
  140. package/lib/utils/type/isSymbol.js +6 -26
  141. package/lib/utils/type/isType.js +4 -18
  142. package/lib/utils/type/isUndefined.js +4 -27
  143. package/lib/validatePassword.js +87 -244
  144. package/lib/waitTime.js +8 -32
  145. package/package.json +21 -25
  146. package/types/ajax.d.ts +38 -95
  147. package/types/blobToDataURL.d.ts +2 -2
  148. package/types/bytesToSize.d.ts +7 -6
  149. package/types/calculateCursorPosition.d.ts +10 -9
  150. package/types/dataURLToBlob.d.ts +5 -5
  151. package/types/divide.d.ts +2 -2
  152. package/types/download.d.ts +22 -38
  153. package/types/fileReader.d.ts +35 -2
  154. package/types/filterTree.d.ts +6 -7
  155. package/types/findTreeNode.d.ts +5 -7
  156. package/types/findTreeNodes.d.ts +5 -7
  157. package/types/findTreeSelect.d.ts +5 -7
  158. package/types/formatBankCard.d.ts +8 -5
  159. package/types/formatMobile.d.ts +7 -4
  160. package/types/formatMoney.d.ts +8 -7
  161. package/types/index.d.ts +125 -55
  162. package/types/isBankCard.d.ts +9 -8
  163. package/types/isBusinessLicense.d.ts +8 -5
  164. package/types/isChinese.d.ts +9 -8
  165. package/types/isEmail.d.ts +1 -1
  166. package/types/isHMCard.d.ts +2 -2
  167. package/types/isIPv4.d.ts +1 -1
  168. package/types/isIPv6.d.ts +1 -1
  169. package/types/isIdCard.d.ts +8 -7
  170. package/types/isMobile.d.ts +1 -1
  171. package/types/isPassport.d.ts +2 -2
  172. package/types/isPassword.d.ts +4 -7
  173. package/types/isPostcode.d.ts +1 -1
  174. package/types/isPromiseLike.d.ts +1 -1
  175. package/types/isQQ.d.ts +1 -1
  176. package/types/isSocialCreditCode.d.ts +8 -5
  177. package/types/isSwiftCode.d.ts +2 -2
  178. package/types/isTWCard.d.ts +6 -5
  179. package/types/isTelephone.d.ts +1 -1
  180. package/types/isUrl.d.ts +2 -2
  181. package/types/isVehicle.d.ts +2 -2
  182. package/types/isWX.d.ts +1 -1
  183. package/types/listToTree.d.ts +12 -12
  184. package/types/minus.d.ts +3 -2
  185. package/types/normalizeString.d.ts +2 -2
  186. package/types/numberToChinese.d.ts +13 -12
  187. package/types/padZero.d.ts +2 -2
  188. package/types/parseIdCard.d.ts +17 -56
  189. package/types/plus.d.ts +3 -2
  190. package/types/randomString.d.ts +2 -2
  191. package/types/replaceChar.d.ts +15 -11
  192. package/types/round.d.ts +2 -2
  193. package/types/safeDate.d.ts +24 -2
  194. package/types/setDataURLPrefix.d.ts +5 -5
  195. package/types/strlen.d.ts +1 -1
  196. package/types/times.d.ts +3 -2
  197. package/types/transformFieldNames.d.ts +12 -10
  198. package/types/treeToList.d.ts +1 -1
  199. package/types/utils/config.d.ts +6 -5
  200. package/types/utils/constants.d.ts +2 -2
  201. package/types/utils/convertToString.d.ts +1 -1
  202. package/types/utils/devWarn.d.ts +1 -1
  203. package/types/utils/math.util.d.ts +15 -9
  204. package/types/utils/type/index.d.ts +7 -0
  205. package/types/utils/type/isArguments.d.ts +1 -1
  206. package/types/utils/type/isArray.d.ts +1 -1
  207. package/types/utils/type/isArrayBuffer.d.ts +1 -1
  208. package/types/utils/type/isBlob.d.ts +1 -1
  209. package/types/utils/type/isBoolean.d.ts +1 -1
  210. package/types/utils/type/isDate.d.ts +1 -1
  211. package/types/utils/type/isError.d.ts +1 -1
  212. package/types/utils/type/isFunction.d.ts +1 -1
  213. package/types/utils/type/isMap.d.ts +1 -1
  214. package/types/utils/type/isNaN.d.ts +1 -1
  215. package/types/utils/type/isNil.d.ts +1 -1
  216. package/types/utils/type/isNull.d.ts +1 -1
  217. package/types/utils/type/isNumber.d.ts +1 -1
  218. package/types/utils/type/isObject.d.ts +1 -1
  219. package/types/utils/type/isRegExp.d.ts +1 -1
  220. package/types/utils/type/isSet.d.ts +1 -1
  221. package/types/utils/type/isString.d.ts +1 -1
  222. package/types/utils/type/isSymbol.d.ts +1 -1
  223. package/types/utils/type/isType.d.ts +1 -1
  224. package/types/utils/type/isUndefined.d.ts +1 -1
  225. package/types/utils/type/isWeakMap.d.ts +1 -1
  226. package/types/utils/type/isWeakSet.d.ts +1 -1
  227. package/types/validatePassword.d.ts +17 -48
  228. package/types/waitTime.d.ts +2 -2
  229. package/esm/interface.doc.js +0 -125
  230. package/esm/interface.type.js +0 -17
  231. package/esm/utils/type/index.js +0 -29
  232. package/esm/utils/type/isArguments.js +0 -22
  233. package/esm/utils/type/isArray.js +0 -22
  234. package/esm/utils/type/isArrayBuffer.js +0 -25
  235. package/esm/utils/type/isBoolean.js +0 -22
  236. package/esm/utils/type/isDate.js +0 -22
  237. package/esm/utils/type/isError.js +0 -22
  238. package/esm/utils/type/isFunction.js +0 -22
  239. package/esm/utils/type/isMap.js +0 -22
  240. package/esm/utils/type/isRegExp.js +0 -22
  241. package/esm/utils/type/isSet.js +0 -22
  242. package/esm/utils/type/isWeakMap.js +0 -22
  243. package/esm/utils/type/isWeakSet.js +0 -22
  244. package/lib/interface.doc.js +0 -127
  245. package/lib/interface.type.js +0 -5
  246. package/lib/utils/type/index.js +0 -146
  247. package/lib/utils/type/isArguments.js +0 -29
  248. package/lib/utils/type/isArray.js +0 -29
  249. package/lib/utils/type/isArrayBuffer.js +0 -32
  250. package/lib/utils/type/isBoolean.js +0 -29
  251. package/lib/utils/type/isDate.js +0 -29
  252. package/lib/utils/type/isError.js +0 -29
  253. package/lib/utils/type/isFunction.js +0 -29
  254. package/lib/utils/type/isMap.js +0 -29
  255. package/lib/utils/type/isRegExp.js +0 -29
  256. package/lib/utils/type/isSet.js +0 -29
  257. package/lib/utils/type/isWeakMap.js +0 -29
  258. package/lib/utils/type/isWeakSet.js +0 -29
  259. package/types/interface.type.d.ts +0 -2
package/lib/listToTree.js CHANGED
@@ -1,138 +1,60 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var isObject = require('./utils/type/isObject.js');
2
5
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _type = require("./utils/type");
8
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
- /**
15
- * 递归处理空子级
16
- *
17
- * @private
18
- * @template {Record<string,any>} [T=Record<string,any>]
19
- * @param {T[]} arr 列表数据
20
- * @param {object} [options] 配置项
21
- * @param {string} [options.childrenField='children'] 子级字段名称
22
- * @param {'none'|'null'} [options.emptyChildrenValue='none'] 子级为空时的值,none表示删除该子级,null表示为null,array表示为[]。
23
- */
24
6
  function processEmptyChildren(arr, options) {
25
- var _ref = options || {},
26
- _ref$childrenField = _ref.childrenField,
27
- childrenField = _ref$childrenField === void 0 ? 'children' : _ref$childrenField,
28
- _ref$emptyChildrenVal = _ref.emptyChildrenValue,
29
- emptyChildrenValue = _ref$emptyChildrenVal === void 0 ? 'none' : _ref$emptyChildrenVal;
30
- arr.forEach(function (item) {
31
- // if (isObject(item) && Array.isArray(item[childrenField])) {
32
- if (item[childrenField].length <= 0) {
33
- if (emptyChildrenValue === 'null') {
34
- // @ts-ignore
35
- item[childrenField] = null;
36
- // } else if (emptyChildrenValue === 'none') { // emptyChildrenValue='array' 不会执行该内部方法
37
- } else {
38
- delete item[childrenField];
39
- }
40
- } else {
41
- processEmptyChildren(item[childrenField], options);
42
- }
43
- // }
44
- });
7
+ var _a = options.childrenField, childrenField = _a === void 0 ? 'children' : _a, _b = options.emptyChildrenValue, emptyChildrenValue = _b === void 0 ? 'none' : _b;
8
+ arr.forEach(function (item) {
9
+ if (item[childrenField].length <= 0) {
10
+ if (emptyChildrenValue === 'null') {
11
+ item[childrenField] = null;
12
+ }
13
+ else {
14
+ delete item[childrenField];
15
+ }
16
+ }
17
+ else {
18
+ processEmptyChildren(item[childrenField], options);
19
+ }
20
+ });
45
21
  }
46
-
47
- /**
48
- * 列表数据转树结构
49
- *
50
- * @static
51
- * @alias module:Tree.listToTree
52
- * @since 4.14.0
53
- * @template {Record<string,any>} [T=Record<string,any>]
54
- * @template {*} [R=T&Record<string,any>]
55
- * @param {T[]} list 列表数据
56
- * @param {object} [options] 配置项
57
- * @param {string} [options.keyField='id'] 当前数据的键值字段名称
58
- * @param {string} [options.parentField='pid'] 当前数据的父级字段名称
59
- * @param {string} [options.childrenField='children'] 子级字段名称
60
- * @param {'none'|'null'|'array'} [options.emptyChildrenValue='none'] 子级为空时的值,none表示删除该子级,null表示为null,array表示为[]。
61
- * @param {'spread'|'self'} [options.nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
62
- * @returns {R[]} 树结构
63
- * @example
64
- *
65
- * const menus = [
66
- * { id: '1', name: '首页', code: 'trade', pid: null },
67
- * { id: '2', name: '交易管理', code: 'trade', pid: null },
68
- * { id: '3', name: '交易查询', code: 'trade-1', pid: '2' },
69
- * { id: '4', name: '交易查询-查询操作', code: 'trade-1-1', pid: '3' },
70
- * { id: '5', name: '权限管理', code: 'authorization', pid: null },
71
- * { id: '6', name: '角色管理', code: 'authorization-1', pid: '5' },
72
- * { id: '7', name: '用户管理', code: 'authorization-2', pid: '5' }
73
- * ];
74
- * listToTree(menus);
75
- * // [{"id":"1","name":"首页","code":"trade","pid":null},{"id":"2","name":"交易管理","code":"trade","pid":null,"children":[{"id":"3","name":"交易查询","code":"trade-1","pid":"2","children":[{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"}]}]},{"id":"5","name":"权限管理","code":"authorization","pid":null,"children":[{"id":"6","name":"角色管理","code":"authorization-1","pid":"5"},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]}]
76
- *
77
- * // 自定义子级字段名
78
- * listToTree(basicMenus, { childrenField: 'childs' });
79
- * // [{"id":"1","name":"首页","code":"trade","pid":null},{"id":"2","name":"交易管理","code":"trade","pid":null,"childs":[{"id":"3","name":"交易查询","code":"trade-1","pid":"2","childs":[{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"}]}]},{"id":"5","name":"权限管理","code":"authorization","pid":null,"childs":[{"id":"6","name":"角色管理","code":"authorization-1","pid":"5"},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]}]
80
- *
81
- */
82
22
  function listToTree(list, options) {
83
- var _ref2 = options || {},
84
- _ref2$keyField = _ref2.keyField,
85
- keyField = _ref2$keyField === void 0 ? 'id' : _ref2$keyField,
86
- _ref2$parentField = _ref2.parentField,
87
- parentField = _ref2$parentField === void 0 ? 'pid' : _ref2$parentField,
88
- _ref2$childrenField = _ref2.childrenField,
89
- childrenField = _ref2$childrenField === void 0 ? 'children' : _ref2$childrenField,
90
- _ref2$emptyChildrenVa = _ref2.emptyChildrenValue,
91
- emptyChildrenValue = _ref2$emptyChildrenVa === void 0 ? 'none' : _ref2$emptyChildrenVa,
92
- _ref2$nodeAssign = _ref2.nodeAssign,
93
- nodeAssign = _ref2$nodeAssign === void 0 ? 'spread' : _ref2$nodeAssign;
94
-
95
- /** @type {R[]} */
96
- var tree = [];
97
-
98
- /** @type {Object.<string, T[]>} */
99
- var record = {};
100
- if (!Array.isArray(list)) {
101
- return tree;
102
- }
103
- list.forEach(function (item) {
104
- if ((0, _type.isObject)(item)) {
105
- var newItem = nodeAssign === 'spread' ? _objectSpread({}, item) : item;
106
-
107
- /** @type {string} */
108
- var id = newItem[keyField];
109
-
110
- /** @type {string} */
111
- var pid = newItem[parentField];
112
- if (record[id]) {
113
- // @ts-ignore
114
- newItem[childrenField] = record[id];
115
- } else {
116
- // @ts-ignore
117
- newItem[childrenField] = record[id] = [];
118
- }
119
- if (pid) {
120
- if (!record[pid]) {
121
- record[pid] = [newItem];
122
- } else {
123
- record[pid].push(newItem);
23
+ if (options === void 0) { options = {}; }
24
+ var _a = options.keyField, keyField = _a === void 0 ? 'id' : _a, _b = options.parentField, parentField = _b === void 0 ? 'pid' : _b, _c = options.childrenField, childrenField = _c === void 0 ? 'children' : _c, _d = options.emptyChildrenValue, emptyChildrenValue = _d === void 0 ? 'none' : _d, _e = options.nodeAssign, nodeAssign = _e === void 0 ? 'spread' : _e;
25
+ var tree = [];
26
+ var record = {};
27
+ if (!Array.isArray(list)) {
28
+ return tree;
29
+ }
30
+ list.forEach(function (item) {
31
+ if (isObject(item)) {
32
+ var newItem = nodeAssign === 'spread' ? tslib.__assign({}, item) : item;
33
+ var id = newItem[keyField];
34
+ var pid = newItem[parentField];
35
+ if (record[id]) {
36
+ newItem[childrenField] = record[id];
37
+ }
38
+ else {
39
+ newItem[childrenField] = record[id] = [];
40
+ }
41
+ if (pid) {
42
+ if (!record[pid]) {
43
+ record[pid] = [newItem];
44
+ }
45
+ else {
46
+ record[pid].push(newItem);
47
+ }
48
+ }
49
+ else {
50
+ tree.push(newItem);
51
+ }
124
52
  }
125
- } else {
126
- // @ts-ignore
127
- tree.push(newItem);
128
- }
53
+ });
54
+ if (emptyChildrenValue !== 'array') {
55
+ processEmptyChildren(tree, options);
129
56
  }
130
- });
131
- if (emptyChildrenValue !== 'array') {
132
- // @ts-ignore
133
- processEmptyChildren(tree, options);
134
- }
135
- return tree;
57
+ return tree;
136
58
  }
137
- var _default = listToTree;
138
- exports["default"] = _default;
59
+
60
+ module.exports = listToTree;
package/lib/minus.js CHANGED
@@ -1,54 +1,26 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _math = require("./utils/math.util");
8
- var _times = _interopRequireDefault(require("./times"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
- /**
17
- * 精确减法,支持多个数相减,减数默认为 0 。
18
- *
19
- * @static
20
- * @alias module:Math.minus
21
- * @since 3.1.0
22
- * @param {...number|string} nums 相减的数
23
- * @returns {number} 差
24
- * @example
25
- *
26
- * minus(1, 0.9); // 0.1
27
- * minus(1, 0.9, 0.02); // 0.08
28
- * minus(1, 0.9, 0.02, 0.08); // 0
29
- *
30
- */
31
- function minus() {
32
- for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
33
- nums[_key] = arguments[_key];
34
- }
35
- var num1 = nums[0],
36
- _nums$ = nums[1],
37
- num2 = _nums$ === void 0 ? 0 : _nums$,
38
- rest = nums.slice(2);
39
- if (rest.length > 0) {
40
- return minus.apply(void 0, [minus(num1, num2)].concat(_toConsumableArray(rest)));
41
- }
42
- num1 = (0, _math.transformEffectiveNumber)(num1);
43
- num2 = (0, _math.transformEffectiveNumber)(num2);
3
+ var tslib = require('tslib');
4
+ var math_util = require('./utils/math.util.js');
5
+ var times = require('./times.js');
6
+ var isNaN = require('./utils/type/isNaN.js');
44
7
 
45
- // 兼容处理,如果参数包含无效数值时,返回 NaN
46
- // @ts-ignore
47
- if (isNaN(num1) || isNaN(num2)) {
48
- return Number.NaN;
49
- }
50
- var baseNum = Math.pow(10, Math.max((0, _math.digitLength)(num1), (0, _math.digitLength)(num2)));
51
- return ((0, _times["default"])(num1, baseNum) - (0, _times["default"])(num2, baseNum)) / baseNum;
8
+ function minus() {
9
+ var nums = [];
10
+ for (var _i = 0; _i < arguments.length; _i++) {
11
+ nums[_i] = arguments[_i];
12
+ }
13
+ var _a = tslib.__read(nums), num1 = _a[0], _b = _a[1], num2 = _b === void 0 ? 0 : _b, rest = _a.slice(2);
14
+ if (rest.length > 0) {
15
+ return minus.apply(void 0, tslib.__spreadArray([minus(num1, num2)], tslib.__read(rest), false));
16
+ }
17
+ num1 = math_util.transformEffectiveNumber(num1);
18
+ num2 = math_util.transformEffectiveNumber(num2);
19
+ if (isNaN(num1) || isNaN(num2)) {
20
+ return Number.NaN;
21
+ }
22
+ var baseNum = Math.pow(10, Math.max(math_util.digitLength(num1), math_util.digitLength(num2)));
23
+ return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
52
24
  }
53
- var _default = minus;
54
- exports["default"] = _default;
25
+
26
+ module.exports = minus;
@@ -1,39 +1,13 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var isNil = require('./utils/type/isNil.js');
4
+ var convertToString = require('./utils/convertToString.js');
2
5
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _isNil = _interopRequireDefault(require("./utils/type/isNil"));
8
- var _convertToString = _interopRequireDefault(require("./utils/convertToString"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
- /**
11
- * 规整化字符串。如果值为 undefined 或 null 将转为空字符串,如果值不是字符串类型将转为字符串。
12
- *
13
- * @static
14
- * @alias module:Processor.normalizeString
15
- * @since 4.3.0
16
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances|String}
17
- * @param {*} value 待处理的值
18
- * @returns {string} 规整化的值
19
- * @example
20
- *
21
- * normalizeString(); // ''
22
- * normalizeString(undefined); // ''
23
- * normalizeString(void 0); // ''
24
- * normalizeString(null); // ''
25
- *
26
- * normalizeString(true); // 'true'
27
- * normalizeString(NaN); // 'NaN'
28
- * normalizeString(1); // '1'
29
- * normalizeString('a'); // 'a'
30
- *
31
- */
32
6
  function normalizeString(value) {
33
- if ((0, _isNil["default"])(value)) {
34
- return '';
35
- }
36
- return (0, _convertToString["default"])(value);
7
+ if (isNil(value)) {
8
+ return '';
9
+ }
10
+ return convertToString(value);
37
11
  }
38
- var _default = normalizeString;
39
- exports["default"] = _default;
12
+
13
+ module.exports = normalizeString;