nhanh-pure-function 3.0.6-beta.13 → 3.0.6-beta.15
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/Element/index.d.ts +2 -2
- package/dist/Utility/index.d.ts +16 -6
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +139 -122
- package/package.json +1 -1
package/dist/Element/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export declare function _Element_IsFullscreen(element?: HTMLElement | string): b
|
|
|
58
58
|
* @param {HTMLElement} content - 需要进入全屏的元素
|
|
59
59
|
* 该函数通过检查不同浏览器的特定方法来实现全屏切换
|
|
60
60
|
*/
|
|
61
|
-
export declare function _Element_Fullscreen(element?: HTMLElement | string): () => void;
|
|
61
|
+
export declare function _Element_Fullscreen(element?: HTMLElement | string): (() => void) | undefined;
|
|
62
62
|
/**
|
|
63
63
|
* 元素全屏状态观察器
|
|
64
64
|
* 监听元素的全屏状态变化,并通过回调函数通知状态改变
|
|
@@ -66,7 +66,7 @@ export declare function _Element_Fullscreen(element?: HTMLElement | string): ()
|
|
|
66
66
|
* @param selectors - 要观察的元素或元素选择器,默认为document.documentElement
|
|
67
67
|
* @returns 返回一个清理函数,调用后可移除所有事件监听器
|
|
68
68
|
*/
|
|
69
|
-
export declare function _Element_FullscreenObserver(notify: (isFull: boolean) => void, selectors?: HTMLElement | string): () => void;
|
|
69
|
+
export declare function _Element_FullscreenObserver(notify: (isFull: boolean) => void, selectors?: HTMLElement | string): (() => void) | undefined;
|
|
70
70
|
/**
|
|
71
71
|
* 单位转换 12** -> **px
|
|
72
72
|
* @param {string} width
|
package/dist/Utility/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param callback 需执行的方法
|
|
4
4
|
* @param timeout 超时时间
|
|
5
5
|
*/
|
|
6
|
-
export declare function _Utility_ExecuteWhenIdle(callback:
|
|
6
|
+
export declare function _Utility_ExecuteWhenIdle(callback: (deadline?: IdleDeadline) => void, timeout?: number): void;
|
|
7
7
|
/**
|
|
8
8
|
* 等待条件满足
|
|
9
9
|
* @param conditionChecker 条件检查器
|
|
@@ -74,12 +74,22 @@ export declare function _Utility_RotateList<T>(list: T[]): T[][];
|
|
|
74
74
|
*/
|
|
75
75
|
export declare function _Utility_Clone<T>(val: T): T;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
* @param
|
|
77
|
+
* 函数装饰器:精准测量并记录目标函数的执行耗时(单位:毫秒)
|
|
78
|
+
*
|
|
79
|
+
* @template T - 泛型参数,约束为任意函数类型,保证装饰器返回值类型与原函数一致
|
|
80
|
+
* @param {T} func - 待测量执行时间的目标函数
|
|
81
|
+
* @param {Object} [config] - 可选配置对象,用于自定义耗时测量规则
|
|
82
|
+
* @param {Array<[number, string]>} [config.level] - 耗时阈值(毫秒)与控制台输出颜色的映射数组
|
|
83
|
+
* 规则:当函数耗时(ms)≥ level[n][0] 时,使用 level[n][1] 指定的颜色输出
|
|
84
|
+
* @param {number} [config.maxHistory=30] - 执行耗时历史记录的最大保留条数,默认值为30
|
|
85
|
+
* @param {string} [config.prefix] - 控制台输出耗时日志时的自定义前缀文本(可选)
|
|
86
|
+
* @returns {T | void} 包装后的函数(保留原函数所有功能,新增耗时测量/记录/日志输出逻辑);若入参非法则返回 void
|
|
81
87
|
*/
|
|
82
|
-
export declare function _Utility_TimeConsumption(func:
|
|
88
|
+
export declare function _Utility_TimeConsumption<T extends Function>(func: T, config?: {
|
|
89
|
+
level?: [number, string][];
|
|
90
|
+
maxHistory?: number;
|
|
91
|
+
prefix?: string;
|
|
92
|
+
}): T | void;
|
|
83
93
|
/**
|
|
84
94
|
* 暂停执行指定毫秒数的操作
|
|
85
95
|
* 此函数通过 busy-wait(忙等待)的方式实现,它会持续执行一些无用的操作以消耗时间
|