Welcome to mirror list, hosted at ThFree Co, Russian Federation.

throttle.js « utils « src « alpinejs « packages « alpinejs - github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c49108b883d021ff7f3bb0a9cf9e5768fd959cc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

export function throttle(func, limit) {
    let inThrottle

    return function() {
        let context = this, args = arguments

        if (! inThrottle) {
            func.apply(context, args)

            inThrottle = true

            setTimeout(() => inThrottle = false, limit)
        }
    }
}