
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
debounce-queue
Advanced tools
Like lodash.debounce but you get an array of all previous (unique) events
Like lodash.debounce
but you get an array of all previous (unique) events instead of just the last/first one.
import {watch} from 'chokidar';
import debounce from 'debounce-queue';
function onChange(files) {
// files is now an array of (unique) files that were changed since (t-1000)ms
}
const debounced = debounce(onChange, 1000);
watch('.')
.on('change', debounced)
You can customize which items get enqueued:
const debounced = debounce(onChange, 1000, {
enqueue( data, queue, defaultEnqueue ) {
if ( queue.indexOf( data ) === -1 ) {
queue.push( data )
}
return queue;
}
});
sleep
(boolean) (default: false)Sleeps while callback is being awaited. Helps prevent feedback loop when a process modifies files in the same path it's watching for changes.
Be sure to return a promise in your callback.
Your debounced function can return a promise
function onChange(files) {
return Promise.map(files, () => {
return Promise.delay(1000);
});
// Next onChange will fire after `delay + files.length * 1000` ms
}
FAQs
Like lodash.debounce but you get an array of all previous (unique) events
The npm package debounce-queue receives a total of 351 weekly downloads. As such, debounce-queue popularity was classified as not popular.
We found that debounce-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.