shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
throttle
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 once each threshhold time
Params
- threshhold*-Number
The delay in ms to wait between two function calls
- fn*-Function
The function to throttle
Return
- -Function
The throttled function
Example
import { throttle } from '@blackbyte/sugar/function';
const myThrottledFn = throttle(1000, () => {
// my function content that will be
// executed only once each second
});
document.addEventListener('scroll', (e) => {
// call my throttled function
myThrottledFn();
});Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space