@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.
- package/dist/array/index.d.ts +2 -2
- package/dist/array/index.js +2 -3
- package/dist/array/slice.js +1 -4
- package/dist/array/sort.js +5 -8
- package/dist/array/tree.d.ts +6 -6
- package/dist/array/tree.js +15 -15
- package/dist/array/unique.d.ts +24 -2
- package/dist/array/unique.js +34 -3
- package/dist/class/index.js +1 -2
- package/dist/class/prefix.d.ts +2 -2
- package/dist/class/prefix.js +3 -4
- package/dist/clone/cloneDeep.js +1 -3
- package/dist/clone/cloneDeepWith.js +4 -7
- package/dist/clone/getTag.js +1 -2
- package/dist/clone/index.js +1 -2
- package/dist/clone/tags.js +1 -2
- package/dist/dom/event.js +1 -2
- package/dist/dom/index.d.ts +3 -2
- package/dist/dom/index.js +3 -3
- package/dist/dom/measure.js +9 -6
- package/dist/{file → dom}/media.d.ts +1 -1
- package/dist/{file → dom}/media.js +37 -20
- package/dist/dom/raf.d.ts +1 -1
- package/dist/dom/raf.js +1 -2
- package/dist/dom/scroll.js +5 -7
- package/dist/{base64/index.d.ts → encoding/base64.d.ts} +2 -2
- package/dist/{base64/index.js → encoding/base64.js} +29 -33
- package/dist/encoding/index.d.ts +2 -0
- package/dist/encoding/index.js +2 -0
- package/dist/file/config.js +6 -2
- package/dist/file/convert.d.ts +6 -2
- package/dist/file/convert.js +7 -3
- package/dist/file/index.d.ts +2 -3
- package/dist/file/index.js +2 -4
- package/dist/file/type.js +7 -10
- package/dist/function/copy.d.ts +7 -0
- package/dist/function/copy.js +8 -2
- package/dist/function/getValue.d.ts +2 -2
- package/dist/function/getValue.js +4 -5
- package/dist/function/index.js +1 -2
- package/dist/function/object.js +1 -2
- package/dist/function/run.js +1 -2
- package/dist/index.d.ts +11 -17
- package/dist/index.js +13 -22
- package/dist/is/base64.d.ts +7 -4
- package/dist/is/base64.js +9 -6
- package/dist/is/browser.js +2 -3
- package/dist/is/deepEqual.d.ts +10 -4
- package/dist/is/deepEqual.js +14 -9
- package/dist/is/device.js +4 -2
- package/dist/is/equal.js +1 -2
- package/dist/is/img.js +1 -2
- package/dist/is/index.d.ts +3 -3
- package/dist/is/index.js +3 -4
- package/dist/is/nil.js +1 -2
- package/dist/is/plainObject.js +2 -4
- package/dist/is/primitive.js +1 -2
- package/dist/is/server.js +1 -2
- package/dist/is/type.js +1 -2
- package/dist/is/typedArray.js +1 -2
- package/dist/is/unsafeProperty.js +1 -2
- package/dist/is/url.js +2 -4
- package/dist/is/valid.js +1 -2
- package/dist/merge/{useDeepMege.d.ts → deepCloneMerge.d.ts} +3 -1
- package/dist/merge/{useDeepMege.js → deepCloneMerge.js} +6 -6
- package/dist/merge/index.d.ts +1 -1
- package/dist/merge/index.js +26 -10
- package/dist/merge/mergeWith.js +1 -4
- package/dist/number/chinese.js +1 -4
- package/dist/number/format.js +7 -6
- package/dist/number/index.js +1 -2
- package/dist/object/classNames.js +1 -5
- package/dist/object/index.js +2 -3
- package/dist/object/omitBoolean.js +1 -2
- package/dist/object/omitUndefined.js +1 -2
- package/dist/object/omitUndefinedAndEmptyArr.js +1 -2
- package/dist/pro-utils.esm.js +625 -402
- package/dist/pro-utils.js +2 -1
- package/dist/{vue/slots.d.ts → slots/index.d.ts} +3 -3
- package/dist/{vue/slots.js → slots/index.js} +34 -20
- package/dist/string/duration.js +1 -2
- package/dist/string/empty.js +1 -2
- package/dist/string/index.d.ts +2 -2
- package/dist/string/index.js +2 -3
- package/dist/string/nanoid.js +1 -2
- package/dist/string/uuid.d.ts +10 -8
- package/dist/string/uuid.js +41 -30
- package/dist/table/column.js +6 -10
- package/dist/table/index.js +1 -2
- package/dist/table/page.js +1 -4
- package/dist/typing.d.ts +2 -2
- package/dist/typing.js +1 -1
- package/package.json +2 -1
- package/dist/clone/symbols.d.ts +0 -10
- package/dist/clone/symbols.js +0 -13
- package/dist/vue/index.d.ts +0 -2
- package/dist/vue/index.js +0 -3
package/dist/is/deepEqual.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
//#region src/is/deepEqual.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
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
|
|
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 (!
|
|
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 (!
|
|
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.
|
|
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 (!
|
|
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
package/dist/is/img.js
CHANGED
package/dist/is/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
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 {
|
|
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
package/dist/is/plainObject.js
CHANGED
|
@@ -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.
|
|
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 };
|
package/dist/is/primitive.js
CHANGED
package/dist/is/server.js
CHANGED
package/dist/is/type.js
CHANGED
package/dist/is/typedArray.js
CHANGED
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/merge/
|
|
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 "../
|
|
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 };
|
package/dist/merge/index.d.ts
CHANGED
package/dist/merge/index.js
CHANGED
|
@@ -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 "./
|
|
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.
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 };
|
package/dist/merge/mergeWith.js
CHANGED
|
@@ -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 };
|
package/dist/number/chinese.js
CHANGED
|
@@ -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 };
|
package/dist/number/format.js
CHANGED
|
@@ -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
|
-
|
|
14
|
-
|
|
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 };
|
package/dist/number/index.js
CHANGED
|
@@ -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 {
|
|
26
|
+
export { classNames as default };
|
package/dist/object/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
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 };
|