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

  1. threshhold*-Number

    The delay in ms to wait between two function calls

  2. fn*-Function

    The function to throttle

Return

  1. -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