1
0
Fork 0
Execute multiple function calls in a timeout amount of time just once
Go to file
Arsen Mirzaev Tatyano-Muradovich 3fb2da32ce remove `default` 2025-01-11 22:38:44 +07:00
LICENSE Initial commit 2024-12-14 17:45:55 +07:00
README.md created 2024-12-14 18:36:10 +07:00
damper.min.mjs minified version 2025-01-11 22:18:38 +07:00
damper.mjs remove `default` 2025-01-11 22:38:44 +07:00

Damper (debouncer, демпфер)

Execute multiple function calls in a timeout amount of time just once

You may also know this technology as a "debouncer" (you are free to use any name)
I prefer "damper", from the word "демпфер"

Example

const dampered = damper(
    (
        a,              // 0
        b,              // 1
        c,              // 2
        force = false,  // 3
        d,              // 4
        resolve,
        reject
    ) => {},
    500,
    3,                  // 3 -> the "force" argument
);
 
dampered('for a', 'for b', 'for c', true, 'for d'); // Enabled forced execution