Tiny debounce for Vue.js



For a mobile project, I was using lodash.debounce, but it has 370 lines of code for something that I could do in 10.

So I created tiny-debounce.

This is what it does.

The code is just 11 lines and look like this:

module.exports = function debounce (fn, delay) {
var timeoutID = null
return function () {
var args = arguments
var that = this
timeoutID = setTimeout(function () {
fn.apply(that, args)
}, delay)

You can learn more about what debounce does in this article.

Like what you read? Give Marcos Neves a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.