Skip to content

Commit

Permalink
Fixed memory leak with debounce arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps committed Nov 6, 2013
1 parent bb74363 commit 2023a10
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions underscore.js
Expand Up @@ -710,14 +710,21 @@
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) result = func.apply(context, args);
if (!immediate) {
result = func.apply(context, args);
context = args = null;
}
}
};
var callNow = immediate && !timeout;
if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) result = func.apply(context, args);
if (callNow) {
result = func.apply(context, args);
context = args = null;
}

return result;
};
};
Expand Down

0 comments on commit 2023a10

Please sign in to comment.