pre-installations and preparations
This commit is contained in:
1 parent
3e5a0329cb
commit
201d621ac3
6977 files changed
+742826
No files matched your search
+4
@@ -0,0 +1,4 @@
|
||||
export interface Cancelable {
|
||||
clear(): void;
|
||||
}
|
||||
export default function debounce<T extends (...args: any[]) => any>(func: T, wait?: number): T & Cancelable;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Corresponds to 10 frames at 60 Hz.
|
||||
// A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
|
||||
export default function debounce(func, wait = 166) {
|
||||
let timeout;
|
||||
function debounced(...args) {
|
||||
const later = () => {
|
||||
// @ts-ignore
|
||||
func.apply(this, args);
|
||||
};
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
}
|
||||
debounced.clear = () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
return debounced;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default } from './debounce';
|
||||
export * from './debounce';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default } from './debounce';
|
||||
export * from './debounce';
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"module": "./index.js",
|
||||
"main": "../node/debounce/index.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
Reference in new issue
Block a user