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

18 lines
354 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) => {
2022-12-31 16:08:42 -06:00
await new Promise((resolve) => {
setTimeout(resolve, ms);
});
};