UNPKG

bonsai-analyzer

Version:
17 lines (15 loc) 254 B
/* * @flow */ export default function debounce( fn: () => void, delay: number = 250, ): () => void { let timer: ?TimeoutID = null; return function() { if (timer) { clearTimeout(timer); } timer = setTimeout(fn, delay); }; }