细节优化
This commit is contained in:
17
src/util.js
17
src/util.js
@@ -1,3 +1,20 @@
|
||||
export const debounce = (fn, delay = 300) => {
|
||||
let timer = null;
|
||||
return async (...args) => {
|
||||
if (timer) clearTimeout(timer);
|
||||
return new Promise((resolve) => {
|
||||
timer = setTimeout(async () => {
|
||||
try {
|
||||
const result = await fn(...args);
|
||||
resolve(result);
|
||||
} finally {
|
||||
timer = null;
|
||||
}
|
||||
}, delay);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export function renderScores(ctx, arrows = []) {
|
||||
let rowIndex = 0;
|
||||
arrows.forEach((item, i) => {
|
||||
|
||||
Reference in New Issue
Block a user