shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
debounce
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.function
This utils function allows you to make sure that a function that will normally be called several times, for example during a scroll event, to be called only once after the delay passed
Params
- delay*-Number
A delay in ms to wait between two function calls
- fn*-Function
The function to debounce
Example
import { debounce } from '@blackbyte/sugar/function';
const myDebouncedFn = debounce(1000, () => {
// my function content that will be
// executed only once after the 1 second delay
});
document.addEventListener('scroll', (e) => {
// call my debounced function
myDebouncedFn();
});Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space