UNPKG

302 BJavaScriptView Raw
1export default function debounce(fn) {
2 var pending;
3 return function () {
4 if (!pending) {
5 pending = new Promise(function (resolve) {
6 Promise.resolve().then(function () {
7 pending = undefined;
8 resolve(fn());
9 });
10 });
11 }
12
13 return pending;
14 };
15}
\No newline at end of file