
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@builtwithjavascript/debounce
Advanced tools
Debounce function hook.
import { useDebounce } from '@builtwithjavascript/debounce'
const debouncedFn = useDebounce(() => {
// do something
}, 350)
window.addEventListener('resize', debouncedFn)
With function type signature (TypeScript), when debugged function takes parameters:
import { useDebounce } from '@builtwithjavascript/debounce'
const yourFunc = (yourFuncParams: TYourFuncParams) => {
// ... do something
}
type TYourFunc = typeof yourFunc; // infer yourFunc type
const debouncedFn = useDebounce<TYourFunc>(yourFunc, 350)
const yourFuncParams = {}
debouncedFn(yourFuncParams)
You can also pass a 3rd parameter to this, with a maximum wait time, similar to lodash debounce:
import { useDebounce } from '@builtwithjavascript/debounce'
// If no invokation after 5000ms due to repeated input,
// the function will be called anyway.
const debouncedFn = useDebounce(() => {
// do something
}, 350, { maxWait: 5000 })
window.addEventListener('resize', debouncedFn)
Optionally, you can get the return value of the function using promise operations:
import { useDebounce } from '@builtwithjavascript/debounce'
const debouncedRequest = useDebounce(() => 'response', 1000)
debouncedRequest().then((value) => {
console.log(value) // 'response'
})
// or use async/await
async function doRequest() {
const value = await debouncedRequest()
console.log(value) // 'response'
}
Code is from @vueuse npm package and used accordingly to the MIT license: https://vueuse.org/shared/useDebounceFn/
FAQs
Debounce function hook useDebounce.
We found that @builtwithjavascript/debounce demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.