@gx-design-vue/pro-utils 0.2.0-alpha.2 → 0.2.0-alpha.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.
Files changed (97) hide show
  1. package/dist/array/index.d.ts +2 -2
  2. package/dist/array/index.js +2 -3
  3. package/dist/array/slice.js +1 -4
  4. package/dist/array/sort.js +5 -8
  5. package/dist/array/tree.d.ts +6 -6
  6. package/dist/array/tree.js +15 -15
  7. package/dist/array/unique.d.ts +24 -2
  8. package/dist/array/unique.js +34 -3
  9. package/dist/class/index.js +1 -2
  10. package/dist/class/prefix.d.ts +2 -2
  11. package/dist/class/prefix.js +3 -4
  12. package/dist/clone/cloneDeep.js +1 -3
  13. package/dist/clone/cloneDeepWith.js +4 -7
  14. package/dist/clone/getTag.js +1 -2
  15. package/dist/clone/index.js +1 -2
  16. package/dist/clone/tags.js +1 -2
  17. package/dist/dom/event.js +1 -2
  18. package/dist/dom/index.d.ts +3 -2
  19. package/dist/dom/index.js +3 -3
  20. package/dist/dom/measure.js +9 -6
  21. package/dist/{file → dom}/media.d.ts +1 -1
  22. package/dist/{file → dom}/media.js +37 -20
  23. package/dist/dom/raf.d.ts +1 -1
  24. package/dist/dom/raf.js +1 -2
  25. package/dist/dom/scroll.js +5 -7
  26. package/dist/{base64/index.d.ts → encoding/base64.d.ts} +2 -2
  27. package/dist/{base64/index.js → encoding/base64.js} +29 -33
  28. package/dist/encoding/index.d.ts +2 -0
  29. package/dist/encoding/index.js +2 -0
  30. package/dist/file/config.js +6 -2
  31. package/dist/file/convert.d.ts +6 -2
  32. package/dist/file/convert.js +7 -3
  33. package/dist/file/index.d.ts +2 -3
  34. package/dist/file/index.js +2 -4
  35. package/dist/file/type.js +7 -10
  36. package/dist/function/copy.d.ts +7 -0
  37. package/dist/function/copy.js +8 -2
  38. package/dist/function/getValue.d.ts +2 -2
  39. package/dist/function/getValue.js +4 -5
  40. package/dist/function/index.js +1 -2
  41. package/dist/function/object.js +1 -2
  42. package/dist/function/run.js +1 -2
  43. package/dist/index.d.ts +11 -17
  44. package/dist/index.js +13 -22
  45. package/dist/is/base64.d.ts +7 -4
  46. package/dist/is/base64.js +9 -6
  47. package/dist/is/browser.js +2 -3
  48. package/dist/is/deepEqual.d.ts +10 -4
  49. package/dist/is/deepEqual.js +14 -9
  50. package/dist/is/device.js +4 -2
  51. package/dist/is/equal.js +1 -2
  52. package/dist/is/img.js +1 -2
  53. package/dist/is/index.d.ts +3 -3
  54. package/dist/is/index.js +3 -4
  55. package/dist/is/nil.js +1 -2
  56. package/dist/is/plainObject.js +2 -4
  57. package/dist/is/primitive.js +1 -2
  58. package/dist/is/server.js +1 -2
  59. package/dist/is/type.js +1 -2
  60. package/dist/is/typedArray.js +1 -2
  61. package/dist/is/unsafeProperty.js +1 -2
  62. package/dist/is/url.js +2 -4
  63. package/dist/is/valid.js +1 -2
  64. package/dist/merge/{useDeepMege.d.ts → deepCloneMerge.d.ts} +3 -1
  65. package/dist/merge/{useDeepMege.js → deepCloneMerge.js} +6 -6
  66. package/dist/merge/index.d.ts +1 -1
  67. package/dist/merge/index.js +26 -10
  68. package/dist/merge/mergeWith.js +1 -4
  69. package/dist/number/chinese.js +1 -4
  70. package/dist/number/format.js +7 -6
  71. package/dist/number/index.js +1 -2
  72. package/dist/object/classNames.js +1 -5
  73. package/dist/object/index.js +2 -3
  74. package/dist/object/omitBoolean.js +1 -2
  75. package/dist/object/omitUndefined.js +1 -2
  76. package/dist/object/omitUndefinedAndEmptyArr.js +1 -2
  77. package/dist/pro-utils.esm.js +625 -402
  78. package/dist/pro-utils.js +2 -1
  79. package/dist/{vue/slots.d.ts → slots/index.d.ts} +3 -3
  80. package/dist/{vue/slots.js → slots/index.js} +34 -20
  81. package/dist/string/duration.js +1 -2
  82. package/dist/string/empty.js +1 -2
  83. package/dist/string/index.d.ts +2 -2
  84. package/dist/string/index.js +2 -3
  85. package/dist/string/nanoid.js +1 -2
  86. package/dist/string/uuid.d.ts +10 -8
  87. package/dist/string/uuid.js +41 -30
  88. package/dist/table/column.js +6 -10
  89. package/dist/table/index.js +1 -2
  90. package/dist/table/page.js +1 -4
  91. package/dist/typing.d.ts +2 -2
  92. package/dist/typing.js +1 -1
  93. package/package.json +2 -1
  94. package/dist/clone/symbols.d.ts +0 -10
  95. package/dist/clone/symbols.js +0 -13
  96. package/dist/vue/index.d.ts +0 -2
  97. package/dist/vue/index.js +0 -3
@@ -1,14 +1,16 @@
1
1
  //#region src/is/deepEqual.ts
2
2
  /**
3
- * React 深度比较
3
+ * 深度比较两个值是否相等
4
+ *
5
+ * 支持数组、Map、Set、TypedArray、RegExp 及普通对象的递归比较。
4
6
  *
5
7
  * @param a - 第一个值
6
8
  * @param b - 第二个值
7
9
  * @param ignoreKeys - 忽略的键
8
- * @param debug - 是否调试
10
+ * @param debug - 是否调试(打印首个不相等的键)
9
11
  * @returns 是否相等
10
12
  */
11
- function isDeepEqualReact(a, b, ignoreKeys, debug) {
13
+ function isDeepEqual(a, b, ignoreKeys, debug) {
12
14
  if (a === b) return true;
13
15
  if (a && b && typeof a === "object" && typeof b === "object") {
14
16
  if (a.constructor !== b.constructor) return false;
@@ -17,13 +19,13 @@ function isDeepEqualReact(a, b, ignoreKeys, debug) {
17
19
  if (Array.isArray(a)) {
18
20
  length = a.length;
19
21
  if (length != b.length) return false;
20
- for (i = length; i-- !== 0;) if (!isDeepEqualReact(a[i], b[i], ignoreKeys, debug)) return false;
22
+ for (i = length; i-- !== 0;) if (!isDeepEqual(a[i], b[i], ignoreKeys, debug)) return false;
21
23
  return true;
22
24
  }
23
25
  if (a instanceof Map && b instanceof Map) {
24
26
  if (a.size !== b.size) return false;
25
27
  for (i of a.entries()) if (!b.has(i[0])) return false;
26
- for (i of a.entries()) if (!isDeepEqualReact(i[1], b.get(i[0]), ignoreKeys, debug)) return false;
28
+ for (i of a.entries()) if (!isDeepEqual(i[1], b.get(i[0]), ignoreKeys, debug)) return false;
27
29
  return true;
28
30
  }
29
31
  if (a instanceof Set && b instanceof Set) {
@@ -43,12 +45,12 @@ function isDeepEqualReact(a, b, ignoreKeys, debug) {
43
45
  const keys = Object.keys(a);
44
46
  length = keys.length;
45
47
  if (length !== Object.keys(b).length) return false;
46
- for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
48
+ for (i = length; i-- !== 0;) if (!Object.hasOwn(b, keys[i])) return false;
47
49
  for (i = length; i-- !== 0;) {
48
50
  const key = keys[i];
49
51
  if (ignoreKeys?.includes(key)) continue;
50
52
  if (key === "_owner" && a.$$typeof) continue;
51
- if (!isDeepEqualReact(a[key], b[key], ignoreKeys, debug)) {
53
+ if (!isDeepEqual(a[key], b[key], ignoreKeys, debug)) {
52
54
  if (debug) console.log(key);
53
55
  return false;
54
56
  }
@@ -57,6 +59,9 @@ function isDeepEqualReact(a, b, ignoreKeys, debug) {
57
59
  }
58
60
  return a !== a && b !== b;
59
61
  }
60
-
62
+ /**
63
+ * @deprecated 请使用 isDeepEqual,该名称为历史遗留(早期移植自 React 实现)
64
+ */
65
+ const isDeepEqualReact = isDeepEqual;
61
66
  //#endregion
62
- export { isDeepEqualReact };
67
+ export { isDeepEqual, isDeepEqualReact };
package/dist/is/device.js CHANGED
@@ -5,6 +5,7 @@
5
5
  * @returns 是否为移动端
6
6
  */
7
7
  function isMobile() {
8
+ if (typeof navigator === "undefined") return false;
8
9
  const userAgent = navigator.userAgent || navigator.vendor;
9
10
  if (/iPhone/.test(userAgent)) return true;
10
11
  if (/Android/.test(userAgent) && /Mobile/.test(userAgent)) return true;
@@ -18,6 +19,7 @@ function isMobile() {
18
19
  * @returns 是否为平板
19
20
  */
20
21
  function isTablet() {
22
+ if (typeof navigator === "undefined" || typeof document === "undefined") return false;
21
23
  const userAgent = navigator.userAgent || navigator.vendor;
22
24
  if (/iPad/.test(userAgent)) return true;
23
25
  if (/Macintosh/.test(userAgent) && "ontouchend" in document) return true;
@@ -30,8 +32,8 @@ function isTablet() {
30
32
  * @returns 是否为 Windows 系统
31
33
  */
32
34
  function isWindowsOs() {
35
+ if (typeof navigator === "undefined") return false;
33
36
  return /windows|win32/i.test(navigator.userAgent);
34
37
  }
35
-
36
38
  //#endregion
37
- export { isMobile, isTablet, isWindowsOs };
39
+ export { isMobile, isTablet, isWindowsOs };
package/dist/is/equal.js CHANGED
@@ -29,6 +29,5 @@ function isEqual(obj1, obj2, shallow = false) {
29
29
  }
30
30
  return deepEqual(obj1, obj2);
31
31
  }
32
-
33
32
  //#endregion
34
- export { isEqual };
33
+ export { isEqual };
package/dist/is/img.js CHANGED
@@ -8,6 +8,5 @@
8
8
  function isImg(path) {
9
9
  return /\w.(?:png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(path);
10
10
  }
11
-
12
11
  //#endregion
13
- export { isImg };
12
+ export { isImg };
@@ -1,6 +1,6 @@
1
- import { isBase64, isDataURLBase64 } from "./base64.js";
1
+ import { isDataURLBase64, isMediaDataURI } from "./base64.js";
2
2
  import { isBrowser } from "./browser.js";
3
- import { isDeepEqualReact } from "./deepEqual.js";
3
+ import { isDeepEqual, isDeepEqualReact } from "./deepEqual.js";
4
4
  import { isMobile, isTablet, isWindowsOs } from "./device.js";
5
5
  import { isEqual } from "./equal.js";
6
6
  import { isImg } from "./img.js";
@@ -13,4 +13,4 @@ import { isTypedArray } from "./typedArray.js";
13
13
  import { isUnsafeProperty } from "./unsafeProperty.js";
14
14
  import { isUrl } from "./url.js";
15
15
  import { convertValueBoolean, isValid } from "./valid.js";
16
- export { convertValueBoolean, is, isArray, isBase64, isBoolean, isBrowser, isDataURLBase64, isDeepEqualReact, isEqual, isFunction, isImg, isJSONStr, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindowsOs };
16
+ export { convertValueBoolean, is, isArray, isBoolean, isBrowser, isDataURLBase64, isDeepEqual, isDeepEqualReact, isEqual, isFunction, isImg, isJSONStr, isMediaDataURI, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindowsOs };
package/dist/is/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { isBase64, isDataURLBase64 } from "./base64.js";
1
+ import { isDataURLBase64, isMediaDataURI } from "./base64.js";
2
2
  import { isBrowser } from "./browser.js";
3
- import { isDeepEqualReact } from "./deepEqual.js";
3
+ import { isDeepEqual, isDeepEqualReact } from "./deepEqual.js";
4
4
  import { isMobile, isTablet, isWindowsOs } from "./device.js";
5
5
  import { isEqual } from "./equal.js";
6
6
  import { isImg } from "./img.js";
@@ -13,5 +13,4 @@ import { isTypedArray } from "./typedArray.js";
13
13
  import { isUnsafeProperty } from "./unsafeProperty.js";
14
14
  import { isUrl } from "./url.js";
15
15
  import { convertValueBoolean, isValid } from "./valid.js";
16
-
17
- export { convertValueBoolean, is, isArray, isBase64, isBoolean, isBrowser, isDataURLBase64, isDeepEqualReact, isEqual, isFunction, isImg, isJSONStr, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindowsOs };
16
+ export { convertValueBoolean, is, isArray, isBoolean, isBrowser, isDataURLBase64, isDeepEqual, isDeepEqualReact, isEqual, isFunction, isImg, isJSONStr, isMediaDataURI, isMobile, isNil, isNotNil, isNumber, isObject, isObjectWithSymbols, isPlainObject, isPrimitive, isServer, isString, isTablet, isTypedArray, isUnsafeProperty, isUrl, isValid, isWindowsOs };
package/dist/is/nil.js CHANGED
@@ -17,6 +17,5 @@ function isNil(val) {
17
17
  function isNotNil(val) {
18
18
  return val !== null && val !== void 0;
19
19
  }
20
-
21
20
  //#endregion
22
- export { isNil, isNotNil };
21
+ export { isNil, isNotNil };
@@ -1,6 +1,5 @@
1
1
  import { getSymbols } from "../function/object.js";
2
2
  import { isObject } from "./type.js";
3
-
4
3
  //#region src/is/plainObject.ts
5
4
  /**
6
5
  * 判断是否为纯对象(plain object)
@@ -12,7 +11,7 @@ function isPlainObject(value) {
12
11
  if (!isObject(value)) return false;
13
12
  const proto = Object.getPrototypeOf(value);
14
13
  if (proto === null) return true;
15
- const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
14
+ const ctor = Object.hasOwn(proto, "constructor") && proto.constructor;
16
15
  return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
17
16
  }
18
17
  /**
@@ -25,6 +24,5 @@ function isObjectWithSymbols(value) {
25
24
  if (!isObject(value)) return false;
26
25
  return getSymbols(value).length > 0;
27
26
  }
28
-
29
27
  //#endregion
30
- export { isObjectWithSymbols, isPlainObject };
28
+ export { isObjectWithSymbols, isPlainObject };
@@ -8,6 +8,5 @@
8
8
  function isPrimitive(value) {
9
9
  return value === null || typeof value !== "object" && typeof value !== "function";
10
10
  }
11
-
12
11
  //#endregion
13
- export { isPrimitive };
12
+ export { isPrimitive };
package/dist/is/server.js CHANGED
@@ -5,6 +5,5 @@
5
5
  * @returns 是否为服务端
6
6
  */
7
7
  const isServer = typeof window === "undefined";
8
-
9
8
  //#endregion
10
- export { isServer };
9
+ export { isServer };
package/dist/is/type.js CHANGED
@@ -79,6 +79,5 @@ function isJSONStr(str) {
79
79
  return false;
80
80
  }
81
81
  }
82
-
83
82
  //#endregion
84
- export { is, isArray, isBoolean, isFunction, isJSONStr, isNumber, isObject, isString };
83
+ export { is, isArray, isBoolean, isFunction, isJSONStr, isNumber, isObject, isString };
@@ -28,6 +28,5 @@
28
28
  function isTypedArray(x) {
29
29
  return ArrayBuffer.isView(x) && !(x instanceof DataView);
30
30
  }
31
-
32
31
  //#endregion
33
- export { isTypedArray };
32
+ export { isTypedArray };
@@ -13,6 +13,5 @@ function isUnsafeProperty(property) {
13
13
  "prototype"
14
14
  ].includes(property);
15
15
  }
16
-
17
16
  //#endregion
18
- export { isUnsafeProperty };
17
+ export { isUnsafeProperty };
package/dist/is/url.js CHANGED
@@ -10,11 +10,9 @@ function isUrl(path) {
10
10
  if (!path.startsWith("http")) return false;
11
11
  try {
12
12
  return !!new URL(path);
13
- } catch (_) {
14
- console.error("isUrl error", _);
13
+ } catch {
15
14
  return false;
16
15
  }
17
16
  }
18
-
19
17
  //#endregion
20
- export { isUrl };
18
+ export { isUrl };
package/dist/is/valid.js CHANGED
@@ -18,6 +18,5 @@ function convertValueBoolean(value) {
18
18
  if (typeof value === "boolean") return value;
19
19
  return !!value;
20
20
  }
21
-
22
21
  //#endregion
23
- export { convertValueBoolean, isValid };
22
+ export { convertValueBoolean, isValid };
@@ -1,4 +1,4 @@
1
- //#region src/merge/useDeepMege.d.ts
1
+ //#region src/merge/deepCloneMerge.d.ts
2
2
  /**
3
3
  * Merges the properties of the source object into a deep clone of the target object.
4
4
  * Unlike `merge`, This function does not modify the original target object.
@@ -10,6 +10,8 @@
10
10
  *
11
11
  * Note that this function does not mutate the target object.
12
12
  *
13
+ * 注意:函数名保留 `use` 前缀为历史命名,本函数是**纯函数**、非 Vue composable,无响应式副作用。
14
+ *
13
15
  * @param {T} target - The target object to be cloned and merged into. This object is not modified directly.
14
16
  * @param {S} source - The source object whose properties will be merged into the cloned target object.
15
17
  * @returns {T & S} A new object with properties from the source object merged into a deep clone of the target object.
@@ -1,8 +1,7 @@
1
1
  import { isPlainObject } from "../is/plainObject.js";
2
- import "../is/index.js";
2
+ import { cloneDeep } from "../clone/cloneDeep.js";
3
3
  import { mergeWith } from "./mergeWith.js";
4
-
5
- //#region src/merge/useDeepMege.ts
4
+ //#region src/merge/deepCloneMerge.ts
6
5
  /**
7
6
  * Merges the properties of the source object into a deep clone of the target object.
8
7
  * Unlike `merge`, This function does not modify the original target object.
@@ -14,6 +13,8 @@ import { mergeWith } from "./mergeWith.js";
14
13
  *
15
14
  * Note that this function does not mutate the target object.
16
15
  *
16
+ * 注意:函数名保留 `use` 前缀为历史命名,本函数是**纯函数**、非 Vue composable,无响应式副作用。
17
+ *
17
18
  * @param {T} target - The target object to be cloned and merged into. This object is not modified directly.
18
19
  * @param {S} source - The source object whose properties will be merged into the cloned target object.
19
20
  * @returns {T & S} A new object with properties from the source object merged into a deep clone of the target object.
@@ -46,11 +47,10 @@ import { mergeWith } from "./mergeWith.js";
46
47
  * // Output: { a: [1, 2, 3] }
47
48
  */
48
49
  function useDeepMerge(target, source) {
49
- return mergeWith(target, source, function mergeRecursively(targetValue, sourceValue) {
50
+ return mergeWith(cloneDeep(target), source, function mergeRecursively(targetValue, sourceValue) {
50
51
  if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) return mergeWith(targetValue, sourceValue, mergeRecursively);
51
52
  else return mergeWith({}, sourceValue, mergeRecursively);
52
53
  });
53
54
  }
54
-
55
55
  //#endregion
56
- export { useDeepMerge };
56
+ export { useDeepMerge };
@@ -1,4 +1,4 @@
1
- import { useDeepMerge } from "./useDeepMege.js";
1
+ import { useDeepMerge } from "./deepCloneMerge.js";
2
2
  import { mergeWith } from "./mergeWith.js";
3
3
 
4
4
  //#region src/merge/index.d.ts
@@ -1,10 +1,7 @@
1
1
  import { isPlainObject } from "../is/plainObject.js";
2
- import "../is/index.js";
3
2
  import { cloneDeep } from "../clone/cloneDeep.js";
4
- import "../clone/index.js";
5
3
  import { mergeWith } from "./mergeWith.js";
6
- import { useDeepMerge } from "./useDeepMege.js";
7
-
4
+ import { useDeepMerge } from "./deepCloneMerge.js";
8
5
  //#region src/merge/index.ts
9
6
  /**
10
7
  * 合并多个对象
@@ -17,7 +14,7 @@ function merge(...rest) {
17
14
  const il = rest.length;
18
15
  let key;
19
16
  let i = 0;
20
- for (; i < il; i += 1) for (key in rest[i]) if (Object.prototype.hasOwnProperty.call(rest[i], key)) if (typeof obj[key] === "object" && typeof rest[i][key] === "object" && obj[key] !== void 0 && obj[key] !== null && !Array.isArray(obj[key]) && !Array.isArray(rest[i][key])) obj[key] = {
17
+ for (; i < il; i += 1) for (key in rest[i]) if (Object.getOwnPropertyDescriptor(rest[i], key)) if (typeof obj[key] === "object" && typeof rest[i][key] === "object" && obj[key] !== void 0 && obj[key] !== null && !Array.isArray(obj[key]) && !Array.isArray(rest[i][key])) obj[key] = {
21
18
  ...obj[key],
22
19
  ...rest[i][key]
23
20
  };
@@ -32,11 +29,30 @@ function merge(...rest) {
32
29
  * @returns 合并后的对象
33
30
  */
34
31
  function deepMerge(target, source) {
35
- return mergeWith(cloneDeep(target), source, function mergeRecursively(targetValue, sourceValue) {
36
- if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) return mergeWith(cloneDeep(targetValue), sourceValue, mergeRecursively);
37
- else return mergeWith({}, sourceValue, mergeRecursively);
32
+ const sourceStack = /* @__PURE__ */ new WeakMap();
33
+ const clonedTarget = cloneDeep(target);
34
+ if (isPlainObject(source)) sourceStack.set(source, clonedTarget);
35
+ const mergedTarget = mergeWith(clonedTarget, source, function mergeRecursively(targetValue, sourceValue) {
36
+ if (isPlainObject(sourceValue)) {
37
+ const cached = sourceStack.get(sourceValue);
38
+ if (cached) return cached;
39
+ if (isPlainObject(targetValue)) {
40
+ const nextTarget = cloneDeep(targetValue);
41
+ sourceStack.set(sourceValue, nextTarget);
42
+ const merged = mergeWith(nextTarget, sourceValue, mergeRecursively);
43
+ sourceStack.delete(sourceValue);
44
+ return merged;
45
+ } else {
46
+ const nextTarget = {};
47
+ sourceStack.set(sourceValue, nextTarget);
48
+ const merged = mergeWith(nextTarget, sourceValue, mergeRecursively);
49
+ sourceStack.delete(sourceValue);
50
+ return merged;
51
+ }
52
+ }
38
53
  });
54
+ if (isPlainObject(source)) sourceStack.delete(source);
55
+ return mergedTarget;
39
56
  }
40
-
41
57
  //#endregion
42
- export { deepMerge, merge, mergeWith, useDeepMerge };
58
+ export { deepMerge, merge, mergeWith, useDeepMerge };
@@ -1,7 +1,5 @@
1
1
  import { isPlainObject } from "../is/plainObject.js";
2
2
  import { isUnsafeProperty } from "../is/unsafeProperty.js";
3
- import "../is/index.js";
4
-
5
3
  //#region src/merge/mergeWith.ts
6
4
  /**
7
5
  * 合并对象(带自定义处理)
@@ -26,6 +24,5 @@ function mergeWith(target, source, merge) {
26
24
  }
27
25
  return target;
28
26
  }
29
-
30
27
  //#endregion
31
- export { mergeWith };
28
+ export { mergeWith };
@@ -1,6 +1,4 @@
1
1
  import { isNumber } from "../is/type.js";
2
- import "../is/index.js";
3
-
4
2
  //#region src/number/chinese.ts
5
3
  /**
6
4
  * 数字转中文
@@ -41,6 +39,5 @@ function toChinesNum(num) {
41
39
  if (noWan.toString().length < 4) noWan = `0${noWan}`;
42
40
  return overWan ? `${getWan(overWan)}万${getWan(noWan)}` : getWan(num);
43
41
  }
44
-
45
42
  //#endregion
46
- export { toChinesNum };
43
+ export { toChinesNum };
@@ -1,7 +1,6 @@
1
1
  import { isNumber } from "../is/type.js";
2
- import "../is/index.js";
3
-
4
2
  //#region src/number/format.ts
3
+ const formatNumberRegexCache = /* @__PURE__ */ new Map();
5
4
  /**
6
5
  * 格式化数字,保留指定小数位
7
6
  *
@@ -10,8 +9,11 @@ import "../is/index.js";
10
9
  * @returns 格式化后的字符串
11
10
  */
12
11
  function formatNumber(fixedNum, value) {
13
- const regexPattern = `^\\d+(?:\\.\\d{0,${fixedNum}})?`;
14
- const match = new RegExp(regexPattern);
12
+ let match = formatNumberRegexCache.get(fixedNum);
13
+ if (!match) {
14
+ match = new RegExp(`^\\d+(?:\\.\\d{0,${fixedNum}})?`);
15
+ formatNumberRegexCache.set(fixedNum, match);
16
+ }
15
17
  const result = value.toString().match(match);
16
18
  if (result) {
17
19
  const formattedValue = result[0];
@@ -67,6 +69,5 @@ function toConvertNumberShow(number, options) {
67
69
  unit: countStr
68
70
  };
69
71
  }
70
-
71
72
  //#endregion
72
- export { formatNumber, toConvertNumberShow };
73
+ export { formatNumber, toConvertNumberShow };
@@ -1,4 +1,3 @@
1
1
  import { toChinesNum } from "./chinese.js";
2
2
  import { formatNumber, toConvertNumberShow } from "./format.js";
3
-
4
- export { formatNumber, toChinesNum, toConvertNumberShow };
3
+ export { formatNumber, toChinesNum, toConvertNumberShow };
@@ -1,6 +1,4 @@
1
1
  import { isArray, isObject, isString } from "../is/type.js";
2
- import "../is/index.js";
3
-
4
2
  //#region src/object/classNames.ts
5
3
  /**
6
4
  * 类名合并工具
@@ -24,7 +22,5 @@ function classNames(...args) {
24
22
  }
25
23
  return classes.filter((el) => el).join(" ");
26
24
  }
27
- var classNames_default = classNames;
28
-
29
25
  //#endregion
30
- export { classNames_default as default };
26
+ export { classNames as default };
@@ -1,6 +1,5 @@
1
- import classNames_default from "./classNames.js";
1
+ import classNames from "./classNames.js";
2
2
  import { omitBoolean } from "./omitBoolean.js";
3
3
  import { omitUndefined } from "./omitUndefined.js";
4
4
  import { omitUndefinedAndEmptyArr } from "./omitUndefinedAndEmptyArr.js";
5
-
6
- export { classNames_default as classNames, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr };
5
+ export { classNames, omitBoolean, omitUndefined, omitUndefinedAndEmptyArr };
@@ -8,6 +8,5 @@
8
8
  function omitBoolean(obj) {
9
9
  if (obj && obj !== true) return obj;
10
10
  }
11
-
12
11
  //#endregion
13
- export { omitBoolean };
12
+ export { omitBoolean };
@@ -13,6 +13,5 @@ function omitUndefined(obj) {
13
13
  if (Object.keys(newObj).length < 1) return;
14
14
  return newObj;
15
15
  }
16
-
17
16
  //#endregion
18
- export { omitUndefined };
17
+ export { omitUndefined };
@@ -14,6 +14,5 @@ function omitUndefinedAndEmptyArr(obj) {
14
14
  });
15
15
  return newObj;
16
16
  }
17
-
18
17
  //#endregion
19
- export { omitUndefinedAndEmptyArr };
18
+ export { omitUndefinedAndEmptyArr };