-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a406f4
commit e59fbf5
Showing
1 changed file
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,25 @@ | ||
# damper.mjs | ||
# Damper (debouncer, демпфер) | ||
|
||
Execute multiple `function` calls in a `timeout` amount of time just once<br> | ||
<br> | ||
You may also know this technology as a "debouncer" (you are free to use any name)<br> | ||
I prefer "damper", from the word "демпфер" | ||
|
||
## Example | ||
```js | ||
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 | ||
``` |