@pawover/kit 0.0.0-alpha.9 → 0.0.0-beta.2
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/enums.d.ts +25 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +25 -0
- package/dist/enums.js.map +1 -0
- package/dist/hooks-alova.d.ts +23 -0
- package/dist/hooks-alova.d.ts.map +1 -0
- package/dist/hooks-alova.js +39 -0
- package/dist/hooks-alova.js.map +1 -0
- package/dist/hooks-react.d.ts +89 -0
- package/dist/hooks-react.d.ts.map +1 -0
- package/dist/hooks-react.js +340 -0
- package/dist/hooks-react.js.map +1 -0
- package/dist/index.d.ts +2445 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1430 -1
- package/dist/index.js.map +1 -0
- package/dist/patches-fetchEventSource.d.ts +806 -0
- package/dist/patches-fetchEventSource.d.ts.map +1 -0
- package/dist/patches-fetchEventSource.js +315 -0
- package/dist/patches-fetchEventSource.js.map +1 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +23 -0
- package/dist/vite.js.map +1 -0
- package/dist/zod.d.ts +105 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +138 -0
- package/dist/zod.js.map +1 -0
- package/metadata.json +160 -0
- package/package.json +51 -35
- package/dist/enums/index.js +0 -20
- package/dist/hooks/react/index.js +0 -5
- package/dist/hooks/react/useCreation.js +0 -19
- package/dist/hooks/react/useLatest.js +0 -13
- package/dist/hooks/react/useMount.js +0 -29
- package/dist/hooks/react/useResponsive.js +0 -59
- package/dist/hooks/react/useUnmount.js +0 -18
- package/dist/types/enums/index.d.ts +0 -20
- package/dist/types/hooks/react/index.d.ts +0 -5
- package/dist/types/hooks/react/useCreation.d.ts +0 -10
- package/dist/types/hooks/react/useLatest.d.ts +0 -8
- package/dist/types/hooks/react/useMount.d.ts +0 -11
- package/dist/types/hooks/react/useResponsive.d.ts +0 -16
- package/dist/types/hooks/react/useUnmount.d.ts +0 -7
- package/dist/types/index.d.ts +0 -1
- package/dist/types/utils/array.d.ts +0 -76
- package/dist/types/utils/clone.d.ts +0 -13
- package/dist/types/utils/index.d.ts +0 -7
- package/dist/types/utils/object.d.ts +0 -54
- package/dist/types/utils/string.d.ts +0 -15
- package/dist/types/utils/to.d.ts +0 -5
- package/dist/types/utils/tree/index.d.ts +0 -6
- package/dist/types/utils/tree/rowsToTree.d.ts +0 -10
- package/dist/types/utils/tree/treeFilter.d.ts +0 -6
- package/dist/types/utils/tree/treeFind.d.ts +0 -8
- package/dist/types/utils/tree/treeForEach.d.ts +0 -5
- package/dist/types/utils/tree/treeMap.d.ts +0 -6
- package/dist/types/utils/tree/treeToRows.d.ts +0 -9
- package/dist/types/utils/tree/types.d.ts +0 -24
- package/dist/types/utils/typeof.d.ts +0 -37
- package/dist/types/zod/index.d.ts +0 -3
- package/dist/types/zod/primitive.d.ts +0 -32
- package/dist/types/zod/validator/input.d.ts +0 -27
- package/dist/types/zod/validator/societal.d.ts +0 -39
- package/dist/utils/array.js +0 -196
- package/dist/utils/clone.js +0 -75
- package/dist/utils/index.js +0 -7
- package/dist/utils/object.js +0 -149
- package/dist/utils/string.js +0 -73
- package/dist/utils/to.js +0 -16
- package/dist/utils/tree/index.js +0 -6
- package/dist/utils/tree/rowsToTree.js +0 -35
- package/dist/utils/tree/treeFilter.js +0 -92
- package/dist/utils/tree/treeFind.js +0 -82
- package/dist/utils/tree/treeForEach.js +0 -60
- package/dist/utils/tree/treeMap.js +0 -79
- package/dist/utils/tree/treeToRows.js +0 -13
- package/dist/utils/tree/types.js +0 -10
- package/dist/utils/typeof.js +0 -149
- package/dist/zod/index.js +0 -3
- package/dist/zod/primitive.js +0 -32
- package/dist/zod/validator/input.js +0 -39
- package/dist/zod/validator/societal.js +0 -57
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type EffectCallback } from "react";
|
|
2
|
-
type MountCallback = EffectCallback | AsyncFunc;
|
|
3
|
-
/**
|
|
4
|
-
* 在组件初始化时执行的 Hook
|
|
5
|
-
* - 即使在严格模式下也只执行一次
|
|
6
|
-
* @reference https://ahooks.js.org/hooks/use-mount
|
|
7
|
-
*
|
|
8
|
-
* @param {MountCallback} effect 副作用函数
|
|
9
|
-
*/
|
|
10
|
-
export declare function useMount(effect: MountCallback): void;
|
|
11
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Breakpoint } from "@pawover/types";
|
|
2
|
-
type ResponsiveValues = Record<Breakpoint, boolean>;
|
|
3
|
-
interface ResponsiveHookOptions {
|
|
4
|
-
/**
|
|
5
|
-
* 紧凑布局断点
|
|
6
|
-
* - 低于此断点时使用紧凑布局
|
|
7
|
-
* @default "xl"
|
|
8
|
-
*/
|
|
9
|
-
compactBreakPoint?: Breakpoint;
|
|
10
|
-
}
|
|
11
|
-
export declare function useResponsive(options?: ResponsiveHookOptions): {
|
|
12
|
-
responsive: ResponsiveValues;
|
|
13
|
-
current: Breakpoint;
|
|
14
|
-
isCompact: boolean;
|
|
15
|
-
};
|
|
16
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./utils";
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export declare function toArray<T>(candidate?: T | T[] | false): T[];
|
|
2
|
-
/**
|
|
3
|
-
* 获取数组第一项
|
|
4
|
-
*
|
|
5
|
-
* @param initialList 初始数组
|
|
6
|
-
* @param saveValue 安全值
|
|
7
|
-
*/
|
|
8
|
-
export declare function arrayFirst<T>(initialList: readonly T[], saveValue?: T): T | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* 获取数组最后一项
|
|
11
|
-
*
|
|
12
|
-
* @param initialList 初始数组
|
|
13
|
-
* @param saveValue 安全值
|
|
14
|
-
*/
|
|
15
|
-
export declare function arrayLast<T>(initialList: readonly T[], saveValue?: T): T | undefined;
|
|
16
|
-
export declare function arrayDiff<T>(initialList: readonly T[], diffList: readonly T[], match: (row: T) => PropertyKey): T[];
|
|
17
|
-
/**
|
|
18
|
-
* 数组竞争
|
|
19
|
-
* - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
|
|
20
|
-
*
|
|
21
|
-
* @param initialList 数组
|
|
22
|
-
* @param match 匹配函数
|
|
23
|
-
*/
|
|
24
|
-
export declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T) => T): T | null;
|
|
25
|
-
/**
|
|
26
|
-
* 统计数组的项目出现次数
|
|
27
|
-
* - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
|
|
28
|
-
*
|
|
29
|
-
* @param initialList 初始数组
|
|
30
|
-
* @param match 标识符匹配函数
|
|
31
|
-
*/
|
|
32
|
-
export declare function arrayCounting<T, K extends PropertyKey>(initialList: readonly T[], match: (row: T) => K): Record<string, number>;
|
|
33
|
-
/**
|
|
34
|
-
* 数组项替换
|
|
35
|
-
* - 在给定的数组中,替换符合匹配函数结果的项目。只替换第一个匹配项。始终返回原始数组的副本。
|
|
36
|
-
*
|
|
37
|
-
* @param initialList 初始数组
|
|
38
|
-
* @param newItem 替换项
|
|
39
|
-
* @param match 匹配函数
|
|
40
|
-
*/
|
|
41
|
-
export declare function arrayReplace<T>(initialList: readonly T[], newItem: T, match: (row: T, index: number) => boolean): T[];
|
|
42
|
-
/**
|
|
43
|
-
* 数组选择
|
|
44
|
-
* - 一次性应用 `filter` 和 `map` 操作
|
|
45
|
-
*
|
|
46
|
-
* @param initialList 初始数组
|
|
47
|
-
* @param filter filter 函数
|
|
48
|
-
* @param mapper map 函数
|
|
49
|
-
*/
|
|
50
|
-
export declare function arrayPick<T, K = T>(initialList: readonly T[], filter: (row: T, index: number) => boolean, mapper?: ((row: T, index: number) => K) | undefined): (readonly T[] & unknown[]) | K[];
|
|
51
|
-
/**
|
|
52
|
-
* 数组切分
|
|
53
|
-
* - 将数组以指定的长度切分后,组合在高维数组中
|
|
54
|
-
*
|
|
55
|
-
* @param initialList 初始数组
|
|
56
|
-
* @param size 分割尺寸,默认 `10`
|
|
57
|
-
*/
|
|
58
|
-
export declare function arraySplit<T>(initialList: readonly T[], size?: number): T[][];
|
|
59
|
-
/**
|
|
60
|
-
* 数组迭代
|
|
61
|
-
* - 运行一个函数 n 次以生成一个值,迭代函数将作为还原器运行无数次,然后返回累积值
|
|
62
|
-
*
|
|
63
|
-
* @param count 迭代次数
|
|
64
|
-
* @param iterate 迭代函数
|
|
65
|
-
* @param initialValue 初始值
|
|
66
|
-
*/
|
|
67
|
-
export declare function arrayIterate<T>(count: number, iterate: (currentValue: T, iteration: number) => T, initialValue: T): T;
|
|
68
|
-
/**
|
|
69
|
-
* 数组合并
|
|
70
|
-
* - 通过给定的标识符匹配函数,用第二个数组中的匹配项替换第一个数组中匹配项的所有内容
|
|
71
|
-
*
|
|
72
|
-
* @param initialList 初始数组
|
|
73
|
-
* @param mergeList 待合并数组
|
|
74
|
-
* @param match 标识符匹配函数
|
|
75
|
-
*/
|
|
76
|
-
export declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match: (item: T) => unknown): readonly T[] & unknown[];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface CloningStrategy {
|
|
2
|
-
cloneMap: <K, V>(parent: Map<K, V>, track: (newParent: Map<K, V>) => Map<K, V>, clone: <T>(value: T) => T) => Map<K, V> | null;
|
|
3
|
-
cloneSet: <T>(parent: Set<T>, track: (newParent: Set<T>) => Set<T>, clone: <T>(value: T) => T) => Set<T> | null;
|
|
4
|
-
cloneArray: <T>(parent: readonly T[], track: (newParent: T[]) => T[], clone: <T>(value: T) => T) => T[] | null;
|
|
5
|
-
cloneObject: <T extends AnyObject>(parent: T, track: (newParent: T) => T, clone: <T>(value: T) => T) => T | null;
|
|
6
|
-
cloneOther: <T>(parent: T, track: (newParent: T) => T, clone: <T>(value: T) => T) => T | null;
|
|
7
|
-
}
|
|
8
|
-
export declare const DefaultCloningStrategy: CloningStrategy;
|
|
9
|
-
/**
|
|
10
|
-
* cloneDeep
|
|
11
|
-
* @reference https://github.com/radashi-org/radashi/blob/main/src/object/cloneDeep.ts
|
|
12
|
-
*/
|
|
13
|
-
export declare function cloneDeep<T extends AnyObject>(root: T, customStrategy?: Partial<CloningStrategy>): T;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { NonEmptyObject, UnionToTuple, ValueOf } from "type-fest";
|
|
2
|
-
/**
|
|
3
|
-
* 返回对象的可枚举属性和方法的名称
|
|
4
|
-
* - `Object.keys` 始终返回 `string[]` 类型,此函数可以返回具体类型
|
|
5
|
-
*
|
|
6
|
-
* @param obj 对象
|
|
7
|
-
* @returns 对象所有可枚举的属性的键名
|
|
8
|
-
*/
|
|
9
|
-
export declare function objectKeys<O extends AnyObject>(obj: O): (keyof O)[];
|
|
10
|
-
/**
|
|
11
|
-
* 返回对象的可枚举属性的值数组
|
|
12
|
-
*
|
|
13
|
-
* @param obj 对象
|
|
14
|
-
*/
|
|
15
|
-
export declare function objectValues<O extends AnyObject>(obj: O): UnionToTuple<ValueOf<O>>;
|
|
16
|
-
/**
|
|
17
|
-
* 返回对象的可枚举属性的键/值数组
|
|
18
|
-
*
|
|
19
|
-
* @param obj 对象
|
|
20
|
-
*/
|
|
21
|
-
export declare function objectEntries<O extends AnyObject>(obj: O): [string & keyof O, O[keyof O]][];
|
|
22
|
-
/**
|
|
23
|
-
* 对象反转
|
|
24
|
-
* - 返回交换了对象的可枚举属性的值/键对象
|
|
25
|
-
*
|
|
26
|
-
* @param obj 对象
|
|
27
|
-
*/
|
|
28
|
-
export declare function objectSwitch<O extends AnyObject>(obj: NonEmptyObject<O>): Record<O[keyof O], keyof O>;
|
|
29
|
-
/**
|
|
30
|
-
* 对象合并
|
|
31
|
-
* - 将两个对象递归合并为一个新对象,从右到左依次使用数值
|
|
32
|
-
* - 递归只适用于子对象属性
|
|
33
|
-
*/
|
|
34
|
-
export declare function objectAssign<O extends AnyObject>(obj: O, overrideObj: O): O;
|
|
35
|
-
export declare function objectPick<O extends AnyObject, K extends keyof O>(obj: O, keys: readonly K[]): Pick<O, K>;
|
|
36
|
-
/**
|
|
37
|
-
* 获取枚举所有属性的键
|
|
38
|
-
*
|
|
39
|
-
* @param enumeration 枚举
|
|
40
|
-
*/
|
|
41
|
-
export declare function enumKeys<E extends AnyObject>(enumeration: NonEmptyObject<E>): [keyof E, ...(keyof E)[]];
|
|
42
|
-
/**
|
|
43
|
-
* 获取枚举所有属性的值
|
|
44
|
-
*
|
|
45
|
-
* @param enumeration 枚举
|
|
46
|
-
*/
|
|
47
|
-
export declare function enumValues<E extends AnyObject>(enumeration: NonEmptyObject<E>): UnionToTuple<ValueOf<E>>;
|
|
48
|
-
/**
|
|
49
|
-
* 返回枚举的属性的键/值数组
|
|
50
|
-
*
|
|
51
|
-
* @param enumeration 枚举
|
|
52
|
-
*/
|
|
53
|
-
export declare function enumEntries<E extends AnyObject>(enumeration: NonEmptyObject<E>): [keyof E, E[keyof E]][];
|
|
54
|
-
export declare function mapEntries<TKey extends PropertyKey, TValue, TNewKey extends PropertyKey, TNewValue>(obj: UnknownObject<TKey, TValue>, toEntry: (key: TKey, value: TValue) => [TNewKey, TNewValue]): UnknownObject<TNewKey, TNewValue>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Replace } from "type-fest";
|
|
2
|
-
/**
|
|
3
|
-
* 转义特殊字符
|
|
4
|
-
*
|
|
5
|
-
* @link https://github.com/sindresorhus/escape-string-regexp
|
|
6
|
-
* @param value 字符串
|
|
7
|
-
*/
|
|
8
|
-
export declare function escapeStringRegexp(value: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* 首字母大小写
|
|
11
|
-
*/
|
|
12
|
-
export declare function stringInitialCase(value: string, type: "lower" | "upper"): string;
|
|
13
|
-
export declare function stringToJson<R extends AnyObject = AnyObject, D extends R = R>(data: string | null | undefined, safeValue: D): R;
|
|
14
|
-
export declare function stringToValues<T extends number | string = number>(data: string | null | undefined, valueType?: "number" | "string"): T[];
|
|
15
|
-
export declare function stringReplace<I extends string, S extends string, R extends string>(input: I, search: S, replacement: R): Replace<I, S, R>;
|
package/dist/types/utils/to.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ChildrenKey, ParentIdKey, RowKey } from "./types";
|
|
2
|
-
export interface RowsToTreeOptions<RK extends string = RowKey, PK extends string = ParentIdKey, CK extends string = ChildrenKey> {
|
|
3
|
-
rowKey?: RK;
|
|
4
|
-
parentIdKey?: PK;
|
|
5
|
-
childrenKey?: CK;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* 行结构 转 树结构
|
|
9
|
-
*/
|
|
10
|
-
export declare function rowsToTree<T extends AnyObject = AnyObject, CK extends string = ChildrenKey, R = TreeLike<T, CK>, RK extends string = RowKey, PK extends string = ParentIdKey>(rows: T[], options?: RowsToTreeOptions<RK, PK, CK> | undefined): R[];
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type BaseCallbackMeta, type BaseInnerOptions, type BaseOptions, type ChildrenKey } from "./types";
|
|
2
|
-
export type TreeFilterOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
|
|
3
|
-
export type TreeFilterInnerOption<T extends AnyObject, CK extends string = ChildrenKey> = BaseInnerOptions<T, CK>;
|
|
4
|
-
export type TreeFilterCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
|
|
5
|
-
export declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T[];
|
|
6
|
-
export declare function treeFilter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type BaseCallbackMeta, type BaseInnerOptions, type BaseOptions, type ChildrenKey } from "./types";
|
|
2
|
-
export type TreeFindOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
|
|
3
|
-
export type TreeFindInnerOption<T extends AnyObject, CK extends string = ChildrenKey> = BaseInnerOptions<T, CK>;
|
|
4
|
-
export type TreeFindCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
|
|
5
|
-
/**
|
|
6
|
-
* 查找树节点,找到第一个返回非空值的节点
|
|
7
|
-
*/
|
|
8
|
-
export declare function treeFind<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeFindCallback<T>, options?: TreeFindOptions<T, CK>): T | undefined;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type BaseCallbackMeta, type BaseInnerOptions, type BaseOptions, type ChildrenKey } from "./types";
|
|
2
|
-
export type TreeForeachOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
|
|
3
|
-
export type TreeForeachInnerOption<T extends AnyObject, CK extends string = ChildrenKey> = BaseInnerOptions<T, CK>;
|
|
4
|
-
export type TreeForeachCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => void;
|
|
5
|
-
export declare function treeForEach<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeForeachCallback<T>, options?: TreeForeachOptions<T, CK>): void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type BaseCallbackMeta, type BaseInnerOptions, type BaseOptions, type ChildrenKey } from "./types";
|
|
2
|
-
export type TreeMapOptions<T extends AnyObject, CK extends string> = BaseOptions<T, CK>;
|
|
3
|
-
export type TreeMapInnerOption<T extends AnyObject, CK extends string> = BaseInnerOptions<T, CK>;
|
|
4
|
-
export type TreeMapCallback<R extends AnyObject, T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => R;
|
|
5
|
-
export declare function treeMap<R extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeMapCallback<R, T>, options?: TreeMapOptions<T, CK>): TreeLike<R, CK>[];
|
|
6
|
-
export declare function treeMap<R extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeMapCallback<R, T>, options?: TreeMapOptions<T, CK>): TreeLike<R, CK>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SetOptional } from "type-fest";
|
|
2
|
-
import { type TreeForeachOptions } from "./treeForEach";
|
|
3
|
-
import type { ChildrenKey } from "./types";
|
|
4
|
-
type TreeToRowsOptions<T extends AnyObject, CK extends string = ChildrenKey> = TreeForeachOptions<T, CK>;
|
|
5
|
-
/**
|
|
6
|
-
* 树结构 转 行结构
|
|
7
|
-
*/
|
|
8
|
-
export declare function treeToRows<T extends AnyObject, CK extends string = ChildrenKey, R extends AnyObject = SetOptional<T, CK>>(tree: T | T[], options?: TreeToRowsOptions<T, CK>): R[];
|
|
9
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type RowKey = "id";
|
|
2
|
-
export type ParentIdKey = "parentId";
|
|
3
|
-
export type ChildrenKey = "children";
|
|
4
|
-
export type Strategy = "pre" | "post" | "breadth";
|
|
5
|
-
export interface BaseCallbackMeta<T> {
|
|
6
|
-
depth: number;
|
|
7
|
-
parents?: T[];
|
|
8
|
-
}
|
|
9
|
-
export interface BaseOptions<T, CK extends string> {
|
|
10
|
-
childrenKey?: CK;
|
|
11
|
-
strategy?: Strategy;
|
|
12
|
-
getChildrenKey?: (row: T, meta: BaseCallbackMeta<T>) => CK | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface BaseInnerOptions<T, CK extends string> {
|
|
15
|
-
childrenKey: CK;
|
|
16
|
-
parents: T[];
|
|
17
|
-
depth: number;
|
|
18
|
-
getChildrenKey?: (row: T, meta: BaseCallbackMeta<T>) => CK | undefined;
|
|
19
|
-
}
|
|
20
|
-
export interface QueueItem<T, CK extends string> {
|
|
21
|
-
queueRow: T;
|
|
22
|
-
queueOptions: BaseInnerOptions<T, CK>;
|
|
23
|
-
}
|
|
24
|
-
export declare function getFinalChildrenKey<T, CK extends string>(tree: T, meta: BaseCallbackMeta<T>, options: BaseInnerOptions<T, CK>): CK;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Class } from "type-fest";
|
|
2
|
-
export declare function isString<T extends string>(value: unknown): value is T;
|
|
3
|
-
export declare function isNumber<T extends number>(value: unknown): value is T;
|
|
4
|
-
export declare function isBoolean<T extends boolean>(value: unknown): value is T;
|
|
5
|
-
export declare function isObject<T extends Record<PropertyKey, unknown>>(value: unknown): value is T;
|
|
6
|
-
export declare function isArray<T extends unknown[]>(value: unknown): value is T;
|
|
7
|
-
export declare function isBigInt<T extends bigint>(value: unknown): value is T;
|
|
8
|
-
export declare function isSymbol<T extends symbol>(value: unknown): value is T;
|
|
9
|
-
export declare function isFunction<T extends Func>(value: unknown): value is T;
|
|
10
|
-
export declare function isGeneratorFunction<T extends Func>(value: unknown): value is T;
|
|
11
|
-
export declare function isAsyncFunction<T extends AsyncFunc>(value: unknown): value is T;
|
|
12
|
-
export declare function isPromise<T extends Promise<unknown>>(value: unknown): value is T;
|
|
13
|
-
export declare function isPromiseLike<T extends PromiseLike<unknown>>(value: unknown): value is T;
|
|
14
|
-
export declare function isNull<T extends null>(value: unknown): value is T;
|
|
15
|
-
export declare function isUndefined<T extends undefined>(value: unknown): value is T;
|
|
16
|
-
export declare function isDate<T extends Date>(value: unknown): value is T;
|
|
17
|
-
export declare function isRegExp<T extends RegExp>(value: unknown): value is T;
|
|
18
|
-
export declare function isError<T extends Error>(value: unknown): value is T;
|
|
19
|
-
export declare function isFile<T extends File>(value: unknown): value is T;
|
|
20
|
-
export declare function isMap<T extends Map<unknown, unknown>>(value: unknown): value is T;
|
|
21
|
-
export declare function isWeakMap<T extends WeakMap<AnyObject, unknown>>(value: unknown): value is T;
|
|
22
|
-
export declare function isSet<T extends Set<unknown>>(value: unknown): value is T;
|
|
23
|
-
export declare function isWeakSet<T extends WeakSet<AnyObject>>(value: unknown): value is T;
|
|
24
|
-
export declare function isWindow<T extends Window>(value: unknown): value is T;
|
|
25
|
-
export declare function isWebSocket<T extends WebSocket>(value: unknown): value is T;
|
|
26
|
-
export declare function isURLSearchParams<T extends Window>(value: unknown): value is T;
|
|
27
|
-
export declare function isClass<T extends Class<AnyObject>>(value: unknown): value is T;
|
|
28
|
-
export declare function isInteger<T extends number>(value: unknown): value is T;
|
|
29
|
-
export declare function isIterable<T extends Iterable<unknown>>(value: unknown): value is T;
|
|
30
|
-
/**
|
|
31
|
-
* 判断给定的值是否相等
|
|
32
|
-
* @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
|
|
33
|
-
*
|
|
34
|
-
* @param {T} x
|
|
35
|
-
* @param {T} y
|
|
36
|
-
*/
|
|
37
|
-
export declare function isEqual<T>(x: T, y: T): boolean;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** 空 */
|
|
3
|
-
export declare const empty: z.ZodUnion<readonly [z.ZodNull, z.ZodUndefined]>;
|
|
4
|
-
/** 字符串 */
|
|
5
|
-
export declare const string: z.ZodString;
|
|
6
|
-
/** 字符串-空 */
|
|
7
|
-
export declare const stringEmpty: z.ZodOptional<z.ZodNullable<z.ZodLiteral<"">>>;
|
|
8
|
-
/** 字符串-非空 */
|
|
9
|
-
export declare const stringNoEmpty: z.ZodString;
|
|
10
|
-
/** 字符串-可空 */
|
|
11
|
-
export declare const stringAllowEmpty: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
-
/** 数字 */
|
|
13
|
-
export declare const number: z.ZodNumber;
|
|
14
|
-
/** 数字-可空 */
|
|
15
|
-
export declare const numberAllowEmpty: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
-
/** 整数 */
|
|
17
|
-
export declare const int: z.ZodNumber;
|
|
18
|
-
/** 整数-可空 */
|
|
19
|
-
export declare const intAllowEmpty: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
20
|
-
/** 自然数 */
|
|
21
|
-
export declare const natural: z.ZodNumber;
|
|
22
|
-
/** 自然数-可空 */
|
|
23
|
-
export declare const naturalAllowEmpty: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
24
|
-
/** 布尔值 */
|
|
25
|
-
export declare const boolean: z.ZodBoolean;
|
|
26
|
-
/** 布尔值-可空 */
|
|
27
|
-
export declare const booleanAllowEmpty: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
28
|
-
export declare const bigint: z.ZodBigInt;
|
|
29
|
-
export declare const symbol: z.ZodSymbol;
|
|
30
|
-
export declare const any: z.ZodAny;
|
|
31
|
-
export declare const unknown: z.ZodUnknown;
|
|
32
|
-
export declare const never: z.ZodNever;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** 字母 */
|
|
3
|
-
export declare const alphabet: z.ZodString;
|
|
4
|
-
/** 小写字母 */
|
|
5
|
-
export declare const alphabetLowercase: z.ZodString;
|
|
6
|
-
/** 大写字母 */
|
|
7
|
-
export declare const alphabetUppercase: z.ZodString;
|
|
8
|
-
/** 不包含字母 */
|
|
9
|
-
export declare const alphabetOmit: z.ZodString;
|
|
10
|
-
/** 数字和字母 */
|
|
11
|
-
export declare const numberAlphabet: z.ZodString;
|
|
12
|
-
/** 有符号十进制浮点数字符串 */
|
|
13
|
-
export declare const stringSignedDecimalismFloat: z.ZodString;
|
|
14
|
-
/** 无符号十进制浮点数字符串 */
|
|
15
|
-
export declare const stringUnsignedDecimalismFloat: z.ZodString;
|
|
16
|
-
/** 有符号十进制整数字符串 */
|
|
17
|
-
export declare const stringSignedDecimalismInt: z.ZodString;
|
|
18
|
-
/** 无符号十进制整数字符串 */
|
|
19
|
-
export declare const stringUnsignedDecimalismInt: z.ZodString;
|
|
20
|
-
/** 包含空格 */
|
|
21
|
-
export declare const spaceInclude: z.ZodString;
|
|
22
|
-
/** 首空格 */
|
|
23
|
-
export declare const spaceStart: z.ZodString;
|
|
24
|
-
/** 尾空格 */
|
|
25
|
-
export declare const spaceEnd: z.ZodString;
|
|
26
|
-
/** 首尾空格 */
|
|
27
|
-
export declare const spaceStartEnd: z.ZodIntersection<z.ZodString, z.ZodString>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** 手机号码 */
|
|
3
|
-
export declare const phone: z.ZodString;
|
|
4
|
-
/** 固定电话 */
|
|
5
|
-
export declare const telephone: z.ZodString;
|
|
6
|
-
/** 电子邮箱 */
|
|
7
|
-
export declare const email: z.ZodString;
|
|
8
|
-
/** 中文姓名 */
|
|
9
|
-
export declare const chineseName: z.ZodString;
|
|
10
|
-
/** 手机机身码 */
|
|
11
|
-
export declare const IMEI: z.ZodString;
|
|
12
|
-
/** 身份证号 */
|
|
13
|
-
export declare const ID: z.ZodString;
|
|
14
|
-
/** 链接 */
|
|
15
|
-
export declare const link: z.ZodString;
|
|
16
|
-
/** 端口号网址 */
|
|
17
|
-
export declare const linkPort: z.ZodString;
|
|
18
|
-
/** 统一社会信用代码 */
|
|
19
|
-
export declare const USCC_S: z.ZodString;
|
|
20
|
-
/** 统一社会信用代码 - 15位/18位/20位数字/字母 */
|
|
21
|
-
export declare const USCC: z.ZodString;
|
|
22
|
-
/** 迅雷链接 */
|
|
23
|
-
export declare const thunder: z.ZodString;
|
|
24
|
-
/** windows 文件夹路径 */
|
|
25
|
-
export declare const dirPathWindows: z.ZodString;
|
|
26
|
-
/** windows 文件路径 */
|
|
27
|
-
export declare const filePathWindows: z.ZodString;
|
|
28
|
-
/** linux 文件夹路径 */
|
|
29
|
-
export declare const dirPathLinux: z.ZodString;
|
|
30
|
-
/** linux 文件路径 */
|
|
31
|
-
export declare const filePathLinux: z.ZodString;
|
|
32
|
-
/** 车牌号 新能源 */
|
|
33
|
-
export declare const carCodeGreen: z.ZodString;
|
|
34
|
-
/** 车牌号 非新能源 */
|
|
35
|
-
export declare const carCodeNotGreen: z.ZodString;
|
|
36
|
-
/** 中国省份 */
|
|
37
|
-
export declare const chinaProvince: z.ZodString;
|
|
38
|
-
/** 民族 */
|
|
39
|
-
export declare const nation: z.ZodString;
|
package/dist/utils/array.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { isArray, isFunction } from "./typeof";
|
|
2
|
-
export function toArray(candidate) {
|
|
3
|
-
if (candidate === undefined || candidate === false) {
|
|
4
|
-
return [];
|
|
5
|
-
}
|
|
6
|
-
return isArray(candidate) ? candidate : [candidate];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 获取数组第一项
|
|
10
|
-
*
|
|
11
|
-
* @param initialList 初始数组
|
|
12
|
-
* @param saveValue 安全值
|
|
13
|
-
*/
|
|
14
|
-
export function arrayFirst(initialList, saveValue) {
|
|
15
|
-
if (!isArray(initialList) || initialList.length === 0) {
|
|
16
|
-
return saveValue;
|
|
17
|
-
}
|
|
18
|
-
return initialList[0];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 获取数组最后一项
|
|
22
|
-
*
|
|
23
|
-
* @param initialList 初始数组
|
|
24
|
-
* @param saveValue 安全值
|
|
25
|
-
*/
|
|
26
|
-
export function arrayLast(initialList, saveValue) {
|
|
27
|
-
if (!isArray(initialList) || initialList.length === 0) {
|
|
28
|
-
return saveValue;
|
|
29
|
-
}
|
|
30
|
-
return initialList[initialList.length - 1];
|
|
31
|
-
}
|
|
32
|
-
export function arrayDiff(initialList, diffList, match) {
|
|
33
|
-
if (!isArray(initialList) && !isArray(diffList)) {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
if (!isArray(initialList) || !initialList.length) {
|
|
37
|
-
return [...diffList];
|
|
38
|
-
}
|
|
39
|
-
if (!isArray(diffList) || !diffList.length) {
|
|
40
|
-
return [...initialList];
|
|
41
|
-
}
|
|
42
|
-
if (!isFunction(match)) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
const keys = diffList.reduce((prev, curr) => {
|
|
46
|
-
prev[match(curr)] = true;
|
|
47
|
-
return prev;
|
|
48
|
-
}, {});
|
|
49
|
-
return initialList.filter((a) => !keys[match(a)]);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* 数组竞争
|
|
53
|
-
* - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
|
|
54
|
-
*
|
|
55
|
-
* @param initialList 数组
|
|
56
|
-
* @param match 匹配函数
|
|
57
|
-
*/
|
|
58
|
-
export function arrayCompete(initialList, match) {
|
|
59
|
-
if (!isArray(initialList) || initialList.length === 0 || !isFunction(match)) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return initialList.reduce(match);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* 统计数组的项目出现次数
|
|
66
|
-
* - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
|
|
67
|
-
*
|
|
68
|
-
* @param initialList 初始数组
|
|
69
|
-
* @param match 标识符匹配函数
|
|
70
|
-
*/
|
|
71
|
-
export function arrayCounting(initialList, match) {
|
|
72
|
-
if (!isArray(initialList) || !isFunction(match)) {
|
|
73
|
-
return {};
|
|
74
|
-
}
|
|
75
|
-
return initialList.reduce((prev, curr) => {
|
|
76
|
-
const id = match(curr).toString();
|
|
77
|
-
prev[id] = (prev[id] ?? 0) + 1;
|
|
78
|
-
return prev;
|
|
79
|
-
}, {});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* 数组项替换
|
|
83
|
-
* - 在给定的数组中,替换符合匹配函数结果的项目。只替换第一个匹配项。始终返回原始数组的副本。
|
|
84
|
-
*
|
|
85
|
-
* @param initialList 初始数组
|
|
86
|
-
* @param newItem 替换项
|
|
87
|
-
* @param match 匹配函数
|
|
88
|
-
*/
|
|
89
|
-
export function arrayReplace(initialList, newItem, match) {
|
|
90
|
-
if (!initialList) {
|
|
91
|
-
return [];
|
|
92
|
-
}
|
|
93
|
-
if (newItem === undefined || !isFunction(match)) {
|
|
94
|
-
return [...initialList];
|
|
95
|
-
}
|
|
96
|
-
for (let i = 0; i < initialList.length; i++) {
|
|
97
|
-
const item = initialList[i];
|
|
98
|
-
if (item !== undefined && match(item, i)) {
|
|
99
|
-
return [...initialList.slice(0, i), newItem, ...initialList.slice(i + 1, initialList.length)];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return [...initialList];
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* 数组选择
|
|
106
|
-
* - 一次性应用 `filter` 和 `map` 操作
|
|
107
|
-
*
|
|
108
|
-
* @param initialList 初始数组
|
|
109
|
-
* @param filter filter 函数
|
|
110
|
-
* @param mapper map 函数
|
|
111
|
-
*/
|
|
112
|
-
export function arrayPick(initialList, filter, mapper) {
|
|
113
|
-
if (!isArray(initialList)) {
|
|
114
|
-
return [];
|
|
115
|
-
}
|
|
116
|
-
if (!isFunction(filter)) {
|
|
117
|
-
return initialList;
|
|
118
|
-
}
|
|
119
|
-
const hasMapper = isFunction(mapper);
|
|
120
|
-
return initialList.reduce((prev, curr, index) => {
|
|
121
|
-
if (!filter(curr, index)) {
|
|
122
|
-
return prev;
|
|
123
|
-
}
|
|
124
|
-
if (hasMapper) {
|
|
125
|
-
prev.push(mapper(curr, index));
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
prev.push(curr);
|
|
129
|
-
}
|
|
130
|
-
return prev;
|
|
131
|
-
}, []);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* 数组切分
|
|
135
|
-
* - 将数组以指定的长度切分后,组合在高维数组中
|
|
136
|
-
*
|
|
137
|
-
* @param initialList 初始数组
|
|
138
|
-
* @param size 分割尺寸,默认 `10`
|
|
139
|
-
*/
|
|
140
|
-
export function arraySplit(initialList, size = 10) {
|
|
141
|
-
if (!isArray(initialList)) {
|
|
142
|
-
return [];
|
|
143
|
-
}
|
|
144
|
-
const count = Math.ceil(initialList.length / size);
|
|
145
|
-
return Array.from({ length: count })
|
|
146
|
-
.fill(null)
|
|
147
|
-
.map((_c, i) => {
|
|
148
|
-
return initialList.slice(i * size, i * size + size);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* 数组迭代
|
|
153
|
-
* - 运行一个函数 n 次以生成一个值,迭代函数将作为还原器运行无数次,然后返回累积值
|
|
154
|
-
*
|
|
155
|
-
* @param count 迭代次数
|
|
156
|
-
* @param iterate 迭代函数
|
|
157
|
-
* @param initialValue 初始值
|
|
158
|
-
*/
|
|
159
|
-
export function arrayIterate(count, iterate, initialValue) {
|
|
160
|
-
let result = initialValue;
|
|
161
|
-
if (isFunction(iterate)) {
|
|
162
|
-
for (let i = 1; i <= count; i++) {
|
|
163
|
-
result = iterate(result, i);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* 数组合并
|
|
170
|
-
* - 通过给定的标识符匹配函数,用第二个数组中的匹配项替换第一个数组中匹配项的所有内容
|
|
171
|
-
*
|
|
172
|
-
* @param initialList 初始数组
|
|
173
|
-
* @param mergeList 待合并数组
|
|
174
|
-
* @param match 标识符匹配函数
|
|
175
|
-
*/
|
|
176
|
-
export function arrayMerge(initialList, mergeList, match) {
|
|
177
|
-
if (!isArray(initialList)) {
|
|
178
|
-
return [];
|
|
179
|
-
}
|
|
180
|
-
if (!isArray(mergeList)) {
|
|
181
|
-
return initialList;
|
|
182
|
-
}
|
|
183
|
-
if (!isFunction(match)) {
|
|
184
|
-
return initialList;
|
|
185
|
-
}
|
|
186
|
-
return initialList.reduce((prev, curr) => {
|
|
187
|
-
const matched = mergeList.find((list) => match(curr) === match(list));
|
|
188
|
-
if (matched) {
|
|
189
|
-
prev.push(matched);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
prev.push(curr);
|
|
193
|
-
}
|
|
194
|
-
return prev;
|
|
195
|
-
}, []);
|
|
196
|
-
}
|