ph-utils 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.d.ts +1 -1
- package/lib/index.js +5 -6
- package/lib/index_m.d.ts +1 -1
- package/lib/index_m.js +5 -6
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
@@ -58,4 +58,4 @@ export declare class BaseError extends Error {
|
|
58
58
|
* @param wait 需要节流的毫秒
|
59
59
|
* @returns
|
60
60
|
*/
|
61
|
-
export declare function throttle<T extends (...args: any) => any>(func: T, wait
|
61
|
+
export declare function throttle<T extends (...args: any) => any>(func: T, wait?: number): (...args: any[]) => void;
|
package/lib/index.js
CHANGED
@@ -83,14 +83,13 @@ exports.BaseError = BaseError;
|
|
83
83
|
* @param wait 需要节流的毫秒
|
84
84
|
* @returns
|
85
85
|
*/
|
86
|
-
function throttle(func, wait) {
|
87
|
-
let
|
86
|
+
function throttle(func, wait = 300) {
|
87
|
+
let t = -1;
|
88
88
|
return function (...args) {
|
89
|
-
|
90
|
-
|
89
|
+
clearTimeout(t);
|
90
|
+
t = setTimeout(() => {
|
91
91
|
func(...args);
|
92
|
-
|
93
|
-
}
|
92
|
+
}, wait);
|
94
93
|
};
|
95
94
|
}
|
96
95
|
exports.throttle = throttle;
|
package/lib/index_m.d.ts
CHANGED
@@ -58,4 +58,4 @@ export declare class BaseError extends Error {
|
|
58
58
|
* @param wait 需要节流的毫秒
|
59
59
|
* @returns
|
60
60
|
*/
|
61
|
-
export declare function throttle<T extends (...args: any) => any>(func: T, wait
|
61
|
+
export declare function throttle<T extends (...args: any) => any>(func: T, wait?: number): (...args: any[]) => void;
|
package/lib/index_m.js
CHANGED
@@ -70,13 +70,12 @@ export class BaseError extends Error {
|
|
70
70
|
* @param wait 需要节流的毫秒
|
71
71
|
* @returns
|
72
72
|
*/
|
73
|
-
export function throttle(func, wait) {
|
74
|
-
let
|
73
|
+
export function throttle(func, wait = 300) {
|
74
|
+
let t = -1;
|
75
75
|
return function (...args) {
|
76
|
-
|
77
|
-
|
76
|
+
clearTimeout(t);
|
77
|
+
t = setTimeout(() => {
|
78
78
|
func(...args);
|
79
|
-
|
80
|
-
}
|
79
|
+
}, wait);
|
81
80
|
};
|
82
81
|
}
|