lodash.debounce
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Lodash.debounce is a utility function from the Lodash library that's exported as a standalone Node.js module. It provides functionality to delay the execution of a function until after a given wait time in milliseconds has passed since the last time the debounced function was invoked. This is particularly useful for rate-limiting execution of a function, for event handlers, or for reducing the number of costly computations.
In order to use lodash.debounce, you need to first install it using npm. Open up your terminal and run the following commands:
$ {sudo -H} npm i -g npm
$ npm i --save lodash.debounce
After installing, you can require it in your Node.js application with:
var debounce = require('lodash.debounce');
Once required, you can use the debounce function like so:
var myEfficientFn = debounce(function() {
// All the taxing tasks you do
}, 250);
window.addEventListener('resize', myEfficientFn);
In this case, myEfficientFn
will only actually be invoked once every 250 milliseconds, no matter how many times the 'resize' event is fired.
For additional details regarding lodash.debounce, you can browse the official lodash documentation at https://lodash.com/docs#debounce. You can also inspect the complete lodash.debounce
package source at its GitHub repository https://github.com/lodash/lodash/blob/4.0.8-npm-packages/lodash.debounce.