nhanh-pure-function 2.0.5 → 3.0.0
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/Animate/index.d.ts +45 -0
- package/dist/Animate/type.d.ts +0 -0
- package/dist/Blob/index.d.ts +10 -0
- package/dist/Blob/type.d.ts +0 -0
- package/dist/Browser/index.d.ts +52 -0
- package/dist/Browser/type.d.ts +0 -0
- package/dist/{User → Element}/index.d.ts +11 -11
- package/dist/File/index.d.ts +19 -0
- package/dist/File/type.d.ts +0 -0
- package/dist/Format/index.d.ts +75 -0
- package/dist/Format/type.d.ts +0 -0
- package/dist/Math/index.d.ts +26 -55
- package/dist/Math/type.d.ts +0 -4
- package/dist/Utility/index.d.ts +22 -223
- package/dist/Valid/index.d.ts +122 -0
- package/dist/Valid/type.d.ts +4 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.es.js +719 -624
- package/package.json +1 -1
- /package/dist/{User → Element}/type.d.ts +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 进度
|
|
3
|
+
* @param {(schedule)=>void} callback callback( 进度百分比 )
|
|
4
|
+
* @param {Number} TIME 总时长
|
|
5
|
+
* @returns {Function} 停止函数
|
|
6
|
+
*/
|
|
7
|
+
export declare function _Animate_Schedule(callback: (schedule: number) => void, TIME?: number): () => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 创建指定范围的振荡器,在最小值和最大值之间循环变化
|
|
10
|
+
* @param initialMin - 振荡器初始最小值
|
|
11
|
+
* @param initialMax - 振荡器初始最大值
|
|
12
|
+
* @param initialSteps - 从最小值到最大值所需的动画步数
|
|
13
|
+
* @param callback - 每帧更新时的回调函数,接收当前振荡值
|
|
14
|
+
* @param precision - 数值精度(保留小数位数,默认2位)
|
|
15
|
+
* @returns 振荡器控制对象,包含播放/暂停/参数更新等方法
|
|
16
|
+
*/
|
|
17
|
+
export declare function _Animate_CreateOscillator(initialMin: number, initialMax: number, initialSteps: number, callback: (value: number) => void, precision?: number): {
|
|
18
|
+
/** 启动/继续动画 */
|
|
19
|
+
play(target?: number): void;
|
|
20
|
+
/** 暂停动画 */
|
|
21
|
+
pause(): void;
|
|
22
|
+
/** 获取当前值 */
|
|
23
|
+
getCurrent: () => number;
|
|
24
|
+
/** 是否正在运行 */
|
|
25
|
+
isPlaying: () => boolean;
|
|
26
|
+
/** 更新参数(不中断动画) */
|
|
27
|
+
updateParams: (newMin: number, newMax: number, newSteps: number) => boolean;
|
|
28
|
+
/** 获取当前参数 */
|
|
29
|
+
getParams: () => {
|
|
30
|
+
min: number;
|
|
31
|
+
max: number;
|
|
32
|
+
steps: number;
|
|
33
|
+
precision: number;
|
|
34
|
+
stepSize: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 动画过渡数值变化
|
|
39
|
+
* @param startValue - 起始值
|
|
40
|
+
* @param targetValue - 目标值
|
|
41
|
+
* @param stepCount - 动画步数
|
|
42
|
+
* @param callback - 每帧回调函数
|
|
43
|
+
* @param precision - 数值精度(默认2位小数)
|
|
44
|
+
*/
|
|
45
|
+
export declare function _Animate_NumericTransition(startValue: number, targetValue: number, stepCount: number, callback: (currentValue: number) => void, precision?: number): void;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将不同格式的数据转换为图像 URL
|
|
3
|
+
* 此函数支持多种类型的数据输入,包括字符串(Base64/Data URL)、ArrayBuffer、Uint8Array和File,
|
|
4
|
+
* 并尝试将这些数据转换为指定MIME类型的图像URL
|
|
5
|
+
*
|
|
6
|
+
* @param data - 输入数据,可以是字符串(Base64/Data URL)、ArrayBuffer、Uint8Array或File实例
|
|
7
|
+
* @param mimeType - 期望的图像MIME类型,默认为'image/png'
|
|
8
|
+
* @returns 成功时返回图像的URL,失败时返回null
|
|
9
|
+
*/
|
|
10
|
+
export declare function _Blob_ConvertDataToImageUrl(data: string | ArrayBuffer | Uint8Array | File, mimeType?: string): string | void | null;
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { WindowTarget } from '../Constant';
|
|
2
|
+
/**
|
|
3
|
+
* 获取帧率
|
|
4
|
+
* @param {(fps , frameTime)=>void} callback callback( 帧率 , 每帧时间 )
|
|
5
|
+
* @param {Number} referenceNode 参考节点数量
|
|
6
|
+
*/
|
|
7
|
+
export declare function _Browser_GetFrameRate(callback: (fps: number, frameTime: number) => void, referenceNode?: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* 复制到剪贴板
|
|
10
|
+
* @param {string} text
|
|
11
|
+
*/
|
|
12
|
+
export declare function _Browser_CopyToClipboard(text: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* 管理通过键值对打开的窗口
|
|
15
|
+
*/
|
|
16
|
+
export declare class _Browser_KeyedWindowManager {
|
|
17
|
+
private static keys;
|
|
18
|
+
/** 请使用静态方法 */
|
|
19
|
+
private constructor();
|
|
20
|
+
/** 添加已有窗口 */
|
|
21
|
+
static add(key: string, win: Window): void;
|
|
22
|
+
/**
|
|
23
|
+
* 根据键打开或聚焦窗口
|
|
24
|
+
* @param key 窗口的唯一键
|
|
25
|
+
* @param url 要打开的URL
|
|
26
|
+
* @param target 窗口的目标
|
|
27
|
+
* @param windowFeatures 新窗口的特性
|
|
28
|
+
* @returns 返回已打开或新打开的窗口
|
|
29
|
+
*/
|
|
30
|
+
static open(key: string, url?: string | URL, target?: WindowTarget, windowFeatures?: string): Window | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* 检查指定键的窗口是否打开
|
|
33
|
+
* @param key 窗口的唯一键
|
|
34
|
+
* @returns 如果窗口打开则返回true,否则返回false
|
|
35
|
+
*/
|
|
36
|
+
static isOpen(key: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 获取与指定键关联的窗口
|
|
39
|
+
* @param key 窗口的唯一键
|
|
40
|
+
* @returns 返回对应的窗口,如果窗口已关闭则返回undefined
|
|
41
|
+
*/
|
|
42
|
+
static getWindow(key: string): Window | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* 关闭与指定键关联的窗口
|
|
45
|
+
* @param key 窗口的唯一键
|
|
46
|
+
*/
|
|
47
|
+
static close(key: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* 关闭所有打开的窗口并清空Map
|
|
50
|
+
*/
|
|
51
|
+
static closeAll(): void;
|
|
52
|
+
}
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import { DragOption, LocalDragOptions, UiLibrary } from './type';
|
|
|
3
3
|
* 滚动结束监听器
|
|
4
4
|
* @param {(trigger: "vertical" | "horizontal") => void} callback
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function _Element_ScrollEndListener(callback: (trigger: "vertical" | "horizontal") => void): (payload: Event) => void;
|
|
7
7
|
/**
|
|
8
8
|
* 点击非指定dom(包含子级dom)时执行 callback
|
|
9
9
|
* @param querySelector 允许点击的 dom 顶层祖先元素选择器
|
|
@@ -13,12 +13,12 @@ export declare function _ScrollEndListener(callback: (trigger: "vertical" | "hor
|
|
|
13
13
|
* @param options.uiLibrary 项目使用的 ui库 , 用于排除 ui库 创建的元素 , 避免点击 ui库 创建的元素时意外的执行 callback
|
|
14
14
|
* @param options.isClickAllowed 是否允许该点击 ( 如果不确定可以返回 undefined )
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function _Element_CloseOnOutsideClick(querySelector: string[], callback: Function, options?: {
|
|
17
17
|
uiLibrary?: UiLibrary[];
|
|
18
18
|
isClickAllowed?: (event: MouseEvent) => boolean | undefined;
|
|
19
19
|
}): void;
|
|
20
20
|
/** 拖拽dom */
|
|
21
|
-
export declare class
|
|
21
|
+
export declare class _Element_Drag {
|
|
22
22
|
#private;
|
|
23
23
|
init(dom: HTMLElement, option?: DragOption): void;
|
|
24
24
|
finish(): void;
|
|
@@ -29,7 +29,7 @@ export declare class _Drag {
|
|
|
29
29
|
mouseup(): void;
|
|
30
30
|
}
|
|
31
31
|
/** 局部拖拽 计算位置距离/百分比 */
|
|
32
|
-
export declare class
|
|
32
|
+
export declare class _Element_LocalDrag {
|
|
33
33
|
#private;
|
|
34
34
|
init(parentDom: HTMLElement, options?: LocalDragOptions): void;
|
|
35
35
|
finish(): void;
|
|
@@ -48,23 +48,23 @@ export declare class _LocalDrag {
|
|
|
48
48
|
mouseup(): void;
|
|
49
49
|
}
|
|
50
50
|
/** 进入全屏模式 */
|
|
51
|
-
export declare function
|
|
51
|
+
export declare function _Element_EnterFullscreen(content?: HTMLElement): Promise<void>;
|
|
52
52
|
/** 退出全屏模式 */
|
|
53
|
-
export declare function
|
|
53
|
+
export declare function _Element_ExitFullscreen(): Promise<void>;
|
|
54
54
|
/** 判断是否处于全屏模式 */
|
|
55
|
-
export declare function
|
|
55
|
+
export declare function _Element_IsFullscreen(content?: HTMLElement): boolean;
|
|
56
56
|
/**
|
|
57
57
|
* 返回一个用于切换全屏模式的函数
|
|
58
58
|
* @param {HTMLElement} content - 需要进入全屏的元素
|
|
59
59
|
* 该函数通过检查不同浏览器的特定方法来实现全屏切换
|
|
60
60
|
*/
|
|
61
|
-
export declare function
|
|
61
|
+
export declare function _Element_Fullscreen(content?: HTMLElement): () => void;
|
|
62
62
|
/**
|
|
63
63
|
* 单位转换 12** -> **px
|
|
64
64
|
* @param {string} width
|
|
65
65
|
* @returns 对应的单位为px的宽
|
|
66
66
|
*/
|
|
67
|
-
export declare function
|
|
67
|
+
export declare function _Element_GetOtherSizeInPixels(width: string, target?: HTMLElement): number;
|
|
68
68
|
/**
|
|
69
69
|
* 根据给定的宽高比和目标元素或尺寸,计算画布的尺寸
|
|
70
70
|
* 此函数旨在适应不同场景下,如何根据宽高比约束,计算出适合的画布大小
|
|
@@ -73,11 +73,11 @@ export declare function _GetOtherSizeInPixels(width: string, target?: HTMLElemen
|
|
|
73
73
|
* @param target 目标元素或尺寸,可以是DOM元素、选择器字符串或尺寸数组
|
|
74
74
|
* @returns 返回计算后的画布尺寸,格式为[宽度, 高度]
|
|
75
75
|
*/
|
|
76
|
-
export declare function
|
|
76
|
+
export declare function _Element_CalculateCanvasSize(aspectRatio: number, target: Element | string | [number, number]): number[] | undefined;
|
|
77
77
|
/**
|
|
78
78
|
* 异步加载图片,并返回图片对象及其宽高比
|
|
79
79
|
* @param src 图片的URL地址
|
|
80
80
|
* @param timeout 超时时间,单位为毫秒,默认为5000ms
|
|
81
81
|
* @returns 一个Promise对象,包含加载的图片对象及其宽高比
|
|
82
82
|
*/
|
|
83
|
-
export declare function
|
|
83
|
+
export declare function _Element_LoadImage(src: string, timeout?: number): Promise<[HTMLImageElement, number]>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 读取文件
|
|
3
|
+
* @param src 文件地址
|
|
4
|
+
* @returns 文件的字符串内容
|
|
5
|
+
*/
|
|
6
|
+
export declare function _File_Read(src: string): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* 下载文件
|
|
9
|
+
* @param {string} href - 文件路径
|
|
10
|
+
* @param {string} [fileName] - 导出文件名
|
|
11
|
+
*/
|
|
12
|
+
export declare function _File_Download(href: string, fileName?: string): Promise<unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* 创建文件并下载
|
|
15
|
+
* @param {BlobPart[]} content 文件内容
|
|
16
|
+
* @param {string} fileName 文件名称
|
|
17
|
+
* @param {BlobPropertyBag} options Blob 配置
|
|
18
|
+
*/
|
|
19
|
+
export declare function _File_CreateAndDownload(content: BlobPart[], fileName: string, options?: BlobPropertyBag): void;
|
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 首字母大写
|
|
3
|
+
* @param str
|
|
4
|
+
* @returns string
|
|
5
|
+
*/
|
|
6
|
+
export declare function _Format_CapitalizeFirstLetter(string: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* 转为百分比字符串
|
|
9
|
+
* @param value 分子
|
|
10
|
+
* @param totalValue 分母
|
|
11
|
+
* @param decimalPlaces 保留小数位
|
|
12
|
+
* @returns 10.00%
|
|
13
|
+
*/
|
|
14
|
+
export declare function _Format_Percentage(value: number, totalValue: number, decimalPlaces?: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* 格式化数字,给数字加上千位分隔符。
|
|
17
|
+
* @param {number} number - 要格式化的数字。
|
|
18
|
+
* @returns {string} - 格式化后的字符串。
|
|
19
|
+
*/
|
|
20
|
+
export declare function _Format_NumberWithCommas(number: number): string;
|
|
21
|
+
/**
|
|
22
|
+
* 将纯数字转换为带单位的数字格式
|
|
23
|
+
*
|
|
24
|
+
* @param value - 要转换的数字或字符串形式的数字
|
|
25
|
+
* @param config - 配置对象
|
|
26
|
+
* @param config.join - 是否将数字和单位拼接成一个字符串,默认为 `false`
|
|
27
|
+
* @param config.suffix - 单位后缀,默认为 `万`
|
|
28
|
+
* @param config.decimalPlaces - 保留的小数位数,默认为 `2`
|
|
29
|
+
*
|
|
30
|
+
* @returns 返回转换后的结果:
|
|
31
|
+
* - 如果 `config.join` 为 `true`,返回拼接后的字符串,如 "12.34万"
|
|
32
|
+
* - 如果 `config.join` 为 `false`,返回一个数组,如 [ 12.34, '万' ]
|
|
33
|
+
*/
|
|
34
|
+
export declare function _Format_NumberWithUnit(value: string | number, config?: {
|
|
35
|
+
join?: boolean;
|
|
36
|
+
suffix?: string;
|
|
37
|
+
decimalPlaces?: number;
|
|
38
|
+
}): string | (string | number)[];
|
|
39
|
+
/**
|
|
40
|
+
* 格式化文件大小
|
|
41
|
+
* @param {number} size
|
|
42
|
+
* @returns string
|
|
43
|
+
*/
|
|
44
|
+
export declare function _Format_FileSize(size: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* 时间戳转换字符串
|
|
47
|
+
* @param {Number | Date} time 时间戳或Date对象
|
|
48
|
+
* @param {String} template 完整模板 --> YYYY MM DD hh mm ss ms
|
|
49
|
+
* @param {Boolean} pad 补0
|
|
50
|
+
*/
|
|
51
|
+
export declare function _Format_Timestamp(time: number | Date, template?: string, pad?: boolean): string;
|
|
52
|
+
/**
|
|
53
|
+
* 从给定的href中提取名称部分
|
|
54
|
+
* 该函数旨在处理URL字符串,并返回URL路径的最后一部分,去除查询参数
|
|
55
|
+
*
|
|
56
|
+
* @param {string} href - 待处理的URL字符串
|
|
57
|
+
* @param {string} [defaultName="file"] - 默认的文件名,当无法提取时使用
|
|
58
|
+
* @returns {string} URL路径的最后一部分,不包括查询参数
|
|
59
|
+
*/
|
|
60
|
+
export declare function _Format_HrefName(href: string, defaultName?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* 驼峰命名
|
|
63
|
+
* @param {字符串} str
|
|
64
|
+
* @param {是否删除分割字符} isRemoveDelimiter
|
|
65
|
+
* @returns 'wq1wqw-qw2qw' -> 'wq1Wqw-Qw2Qw' / 'wqWqwQwQw'
|
|
66
|
+
*/
|
|
67
|
+
export declare function _Format_CamelCase(str: string, isRemoveDelimiter?: boolean): string;
|
|
68
|
+
/**
|
|
69
|
+
* 排除子串
|
|
70
|
+
* @param inputString 需裁剪字符串
|
|
71
|
+
* @param substringToDelete 被裁减字符串
|
|
72
|
+
* @param delimiter 分隔符
|
|
73
|
+
* @returns 裁减后的字符串
|
|
74
|
+
*/
|
|
75
|
+
export declare function _Format_ExcludeSubstring(inputString: string, substringToDelete: string, delimiter?: string): string;
|
|
File without changes
|
package/dist/Math/index.d.ts
CHANGED
|
@@ -1,68 +1,39 @@
|
|
|
1
|
-
import { Point } from './type';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
7
|
-
* @returns 10.00%
|
|
2
|
+
* 将经纬度转换为平面坐标
|
|
3
|
+
* @param lng 经度
|
|
4
|
+
* @param lat 纬度
|
|
5
|
+
* @returns 平面坐标 [x, y](米)
|
|
8
6
|
*/
|
|
9
|
-
export declare function
|
|
7
|
+
export declare function _Math_LngLatToPlane(lng: number, lat: number): [number, number];
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
15
|
-
* @returns 是否在误差内
|
|
9
|
+
* 将平面坐标转换为经纬度
|
|
10
|
+
* @param x 平面坐标 X 值(米)
|
|
11
|
+
* @param y 平面坐标 Y 值(米)
|
|
12
|
+
* @returns 经纬度 [lng, lat](度)
|
|
16
13
|
*/
|
|
17
|
-
export declare function
|
|
14
|
+
export declare function _Math_PlaneToLngLat(x: number, y: number): [number, number];
|
|
18
15
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
16
|
+
* 计算点到线段的距离
|
|
17
|
+
* @param point 点击位置
|
|
18
|
+
* @param lineStart 线段起点
|
|
19
|
+
* @param lineEnd 线段终点
|
|
20
|
+
* @returns 点到线段的距离
|
|
23
21
|
*/
|
|
24
|
-
export declare function
|
|
22
|
+
export declare function _Math_PointToLineDistance(point: [number, number], lineStart: [number, number], lineEnd: [number, number]): number;
|
|
25
23
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param
|
|
28
|
-
* @
|
|
24
|
+
* 计算圆弧的起点和终点坐标
|
|
25
|
+
* @param x 圆心X坐标
|
|
26
|
+
* @param y 圆心Y坐标
|
|
27
|
+
* @param radius 圆弧半径
|
|
28
|
+
* @param startAngle 起始角度(弧度制,0表示X轴正方向)
|
|
29
|
+
* @param endAngle 结束角度(弧度制)
|
|
30
|
+
* @returns [起点坐标[x,y], 终点坐标[x,y]]
|
|
29
31
|
*/
|
|
30
|
-
export declare function
|
|
31
|
-
/**
|
|
32
|
-
* 将纯数字转换为带单位的数字格式
|
|
33
|
-
*
|
|
34
|
-
* @param value - 要转换的数字或字符串形式的数字
|
|
35
|
-
* @param config - 配置对象
|
|
36
|
-
* @param config.join - 是否将数字和单位拼接成一个字符串,默认为 `false`
|
|
37
|
-
* @param config.suffix - 单位后缀,默认为 `万`
|
|
38
|
-
* @param config.decimalPlaces - 保留的小数位数,默认为 `2`
|
|
39
|
-
*
|
|
40
|
-
* @returns 返回转换后的结果:
|
|
41
|
-
* - 如果 `config.join` 为 `true`,返回拼接后的字符串,如 "12.34万"
|
|
42
|
-
* - 如果 `config.join` 为 `false`,返回一个数组,如 [ 12.34, '万' ]
|
|
43
|
-
*/
|
|
44
|
-
export declare function _FormatNumberWithUnit(value: string | number, config?: {
|
|
45
|
-
join?: boolean;
|
|
46
|
-
suffix?: string;
|
|
47
|
-
decimalPlaces?: number;
|
|
48
|
-
}): string | (string | number)[];
|
|
49
|
-
/**
|
|
50
|
-
* 判断点是否在多边形内
|
|
51
|
-
* @param point - 待检测的点,包含 x 和 y 坐标
|
|
52
|
-
* @param polygon - 多边形的点集,数组形式,每个点包含 x 和 y 坐标
|
|
53
|
-
* @returns boolean - 点是否在多边形内
|
|
54
|
-
*/
|
|
55
|
-
export declare function _IsPointInPolygon(point: Point, polygon: Point[]): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* 格式化文件大小
|
|
58
|
-
* @param {number} size
|
|
59
|
-
* @returns string
|
|
60
|
-
*/
|
|
61
|
-
export declare function _FormatFileSize(size: number): string;
|
|
32
|
+
export declare function _Math_GetArcPoints(x: number, y: number, radius: number, startAngle: number, endAngle: number): [[number, number], [number, number]];
|
|
62
33
|
/** 计算平面直角坐标系中两点的距离 */
|
|
63
|
-
export declare function
|
|
34
|
+
export declare function _Math_CalculateDistance2D(x1: number, y1: number, x2: number, y2: number): number;
|
|
64
35
|
/** 获取两点的中点 */
|
|
65
|
-
export declare function
|
|
36
|
+
export declare function _Math_GetMidpoint(x1: number, y1: number, x2: number, y2: number): {
|
|
66
37
|
x: number;
|
|
67
38
|
y: number;
|
|
68
39
|
};
|
package/dist/Math/type.d.ts
CHANGED