@dune2/tools 1.1.3 → 1.1.5
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 +1 -1
- package/src/factory/fieldsMap.tsx +12 -14
- package/src/numbro/index.ts +35 -0
package/package.json
CHANGED
|
@@ -29,11 +29,6 @@ export const fieldsMap: any =
|
|
|
29
29
|
},
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
type DeepKeys<T> =
|
|
33
|
-
T extends Record<string, any>
|
|
34
|
-
? { [K in keyof T]: K | DeepKeys<T[K]> }[keyof T]
|
|
35
|
-
: never;
|
|
36
|
-
|
|
37
32
|
/**
|
|
38
33
|
* FieldsMap 会将对象的所有键(包括嵌套对象中的键)拍平为单层结构,
|
|
39
34
|
* 并将每个键映射为自身的字符串字面量类型。
|
|
@@ -48,12 +43,15 @@ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (
|
|
|
48
43
|
? I
|
|
49
44
|
: never;
|
|
50
45
|
|
|
51
|
-
// 递归收集各层属性(保留原属性引用),数组下钻元素,忽略 undefined/null
|
|
52
|
-
type Pieces<T> = T extends
|
|
53
|
-
?
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
// 递归收集各层属性(保留原属性引用),数组下钻元素,忽略 undefined/null,遇到循环则停止
|
|
47
|
+
type Pieces<T, Seen extends readonly unknown[] = []> = T extends Seen[number]
|
|
48
|
+
? // 已经走过这一层,避免循环
|
|
49
|
+
{}
|
|
50
|
+
: T extends readonly (infer U)[]
|
|
51
|
+
? Pieces<U, Seen>
|
|
52
|
+
: T extends object
|
|
53
|
+
? {
|
|
54
|
+
// 保留原属性引用 + 下钻
|
|
55
|
+
[K in keyof T]-?: Pick<T, K> & Pieces<T[K], [...Seen, T]>;
|
|
56
|
+
}[keyof T]
|
|
57
|
+
: {};
|
package/src/numbro/index.ts
CHANGED
|
@@ -255,6 +255,41 @@ export class Numbro {
|
|
|
255
255
|
return numbro(r);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/**
|
|
259
|
+
* 判断当前数是否大于 other
|
|
260
|
+
*/
|
|
261
|
+
gt(other: OperationParams): boolean {
|
|
262
|
+
return this.bigNumber.isGreaterThan(this.castToBigNumber(other));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 判断当前数是否大于等于 other
|
|
267
|
+
*/
|
|
268
|
+
gte(other: OperationParams): boolean {
|
|
269
|
+
return this.bigNumber.isGreaterThanOrEqualTo(this.castToBigNumber(other));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 判断当前数是否小于 other
|
|
274
|
+
*/
|
|
275
|
+
lt(other: OperationParams): boolean {
|
|
276
|
+
return this.bigNumber.isLessThan(this.castToBigNumber(other));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 判断当前数是否小于等于 other
|
|
281
|
+
*/
|
|
282
|
+
lte(other: OperationParams): boolean {
|
|
283
|
+
return this.bigNumber.isLessThanOrEqualTo(this.castToBigNumber(other));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 判断当前数是否等于 other
|
|
288
|
+
*/
|
|
289
|
+
eq(other: OperationParams): boolean {
|
|
290
|
+
return this.bigNumber.isEqualTo(this.castToBigNumber(other));
|
|
291
|
+
}
|
|
292
|
+
|
|
258
293
|
/**
|
|
259
294
|
* 两个数相除
|
|
260
295
|
* @see https://mikemcl.github.io/bignumber.js/#dividedBy
|