dao-governance-framework/forum-network/public/util.js

16 lines
343 B
JavaScript
Raw Normal View History

const timeouts = new Map();
export const debounce = (fn, delay) => {
const key = fn.toString();
if (!timeouts.get(key)) {
timeouts.set(key, setTimeout(async () => {
timeouts.delete(key);
await fn();
}, delay));
}
};
export const delay = async (ms) => {
await new Promise((resolve) => setTimeout(resolve, ms));
};