@pawover/kit 0.0.0-beta.5 → 0.0.0-beta.50
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/package.json +61 -80
- package/packages/hooks/dist/alova.d.ts +31 -0
- package/packages/hooks/dist/alova.js +64 -0
- package/packages/hooks/dist/index.d.ts +1 -0
- package/packages/hooks/dist/index.js +0 -0
- package/packages/hooks/dist/metadata.json +16 -0
- package/packages/hooks/dist/react.d.ts +164 -0
- package/packages/hooks/dist/react.js +4419 -0
- package/packages/utils/dist/index.d.ts +4293 -0
- package/packages/utils/dist/index.js +1527 -0
- package/packages/utils/dist/math.d.ts +54 -0
- package/packages/utils/dist/math.js +56 -0
- package/packages/utils/dist/metadata.json +14 -0
- package/packages/utils/dist/string-CESQdidv.js +793 -0
- package/packages/utils/dist/vite.d.ts +16 -0
- package/packages/utils/dist/vite.js +26 -0
- package/packages/zod/dist/index.d.ts +58 -0
- package/packages/zod/dist/index.js +61 -0
- package/dist/enums.d.ts +0 -25
- package/dist/enums.d.ts.map +0 -1
- package/dist/enums.js +0 -25
- package/dist/enums.js.map +0 -1
- package/dist/hooks-alova.d.ts +0 -23
- package/dist/hooks-alova.d.ts.map +0 -1
- package/dist/hooks-alova.js +0 -39
- package/dist/hooks-alova.js.map +0 -1
- package/dist/hooks-react.d.ts +0 -89
- package/dist/hooks-react.d.ts.map +0 -1
- package/dist/hooks-react.js +0 -340
- package/dist/hooks-react.js.map +0 -1
- package/dist/index.d.ts +0 -2452
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1441
- package/dist/index.js.map +0 -1
- package/dist/patches-fetchEventSource.d.ts +0 -806
- package/dist/patches-fetchEventSource.d.ts.map +0 -1
- package/dist/patches-fetchEventSource.js +0 -315
- package/dist/patches-fetchEventSource.js.map +0 -1
- package/dist/vite.d.ts +0 -13
- package/dist/vite.d.ts.map +0 -1
- package/dist/vite.js +0 -23
- package/dist/vite.js.map +0 -1
- package/dist/zod.d.ts +0 -105
- package/dist/zod.d.ts.map +0 -1
- package/dist/zod.js +0 -138
- package/dist/zod.js.map +0 -1
- package/metadata.json +0 -161
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BigNumber, MathExpression, MathJsInstance, Matrix } from "mathjs";
|
|
2
|
+
|
|
3
|
+
//#region src/math/mathUtil.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 数学工具类
|
|
6
|
+
* - 基于 [`mathjs`](https://mathjs.org)
|
|
7
|
+
*/
|
|
8
|
+
declare class MathUtil {
|
|
9
|
+
/**
|
|
10
|
+
* 将任意类型的值转换为 `math.bignumber`
|
|
11
|
+
*
|
|
12
|
+
* @param mathJsInstance mathJs 实例
|
|
13
|
+
* @param value 任意类型的值
|
|
14
|
+
* @param fallback 回退值
|
|
15
|
+
* @returns 转换后的 BigNumber
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { create, all } from "mathjs";
|
|
19
|
+
* const math = create(all);
|
|
20
|
+
* MathUtil.toBignumber(math, "0.1");
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
static toBignumber(mathJsInstance: MathJsInstance, value: unknown, fallback?: BigNumber | undefined): BigNumber;
|
|
24
|
+
/**
|
|
25
|
+
* 将任意类型的值转换为十进制数字字符串
|
|
26
|
+
*
|
|
27
|
+
* @param mathJsInstance mathJs 实例
|
|
28
|
+
* @param value 任意类型的值
|
|
29
|
+
* @param precision 精度
|
|
30
|
+
* @param isFormat 是否格式化为字符串
|
|
31
|
+
* @returns 格式化后的字符串或 BigNumber
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* MathUtil.toDecimal(math, 0.12345, 2); // "0.12"
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
static toDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: true | undefined): string;
|
|
38
|
+
static toDecimal(mathJsInstance: MathJsInstance, value: unknown, precision?: number | undefined, isFormat?: false | undefined): BigNumber;
|
|
39
|
+
/**
|
|
40
|
+
* 数学表达式求值
|
|
41
|
+
*
|
|
42
|
+
* @param mathJsInstance mathJs 实例
|
|
43
|
+
* @param expr 表达式
|
|
44
|
+
* @param scope 键值映射
|
|
45
|
+
* @returns 计算结果的字符串表示
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* MathUtil.toEvaluate(math, "a + b", { a: 1, b: 2 }); // "3"
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
static toEvaluate(mathJsInstance: MathJsInstance, expr: MathExpression | Matrix, scope?: Record<string, BigNumber> | undefined): string;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { MathUtil };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { n as TypeUtil, t as StringUtil } from "./string-CESQdidv.js";
|
|
2
|
+
//#region src/math/mathUtil.ts
|
|
3
|
+
/**
|
|
4
|
+
* 数学工具类
|
|
5
|
+
* - 基于 [`mathjs`](https://mathjs.org)
|
|
6
|
+
*/
|
|
7
|
+
var MathUtil = class MathUtil {
|
|
8
|
+
/**
|
|
9
|
+
* 将任意类型的值转换为 `math.bignumber`
|
|
10
|
+
*
|
|
11
|
+
* @param mathJsInstance mathJs 实例
|
|
12
|
+
* @param value 任意类型的值
|
|
13
|
+
* @param fallback 回退值
|
|
14
|
+
* @returns 转换后的 BigNumber
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { create, all } from "mathjs";
|
|
18
|
+
* const math = create(all);
|
|
19
|
+
* MathUtil.toBignumber(math, "0.1");
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
static toBignumber(mathJsInstance, value, fallback) {
|
|
23
|
+
const errorValue = fallback ?? mathJsInstance.bignumber(0);
|
|
24
|
+
if (TypeUtil.isFalsyLike(value) || TypeUtil.isInfinityLike(value)) return errorValue;
|
|
25
|
+
try {
|
|
26
|
+
return mathJsInstance.bignumber(StringUtil.toNumber(`${value}`));
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return errorValue;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
static toDecimal(mathJsInstance, value, precision, isFormat = true) {
|
|
32
|
+
const bigNumber = MathUtil.toBignumber(mathJsInstance, value);
|
|
33
|
+
return isFormat ? mathJsInstance.format(bigNumber, {
|
|
34
|
+
notation: "fixed",
|
|
35
|
+
precision
|
|
36
|
+
}) : bigNumber;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 数学表达式求值
|
|
40
|
+
*
|
|
41
|
+
* @param mathJsInstance mathJs 实例
|
|
42
|
+
* @param expr 表达式
|
|
43
|
+
* @param scope 键值映射
|
|
44
|
+
* @returns 计算结果的字符串表示
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* MathUtil.toEvaluate(math, "a + b", { a: 1, b: 2 }); // "3"
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static toEvaluate(mathJsInstance, expr, scope) {
|
|
51
|
+
const evaluateValue = `${mathJsInstance.evaluate(expr, scope || {})}`;
|
|
52
|
+
return mathJsInstance.format(MathUtil.toBignumber(mathJsInstance, evaluateValue), { notation: "fixed" });
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { MathUtil };
|