Skip to content

Instantly share code, notes, and snippets.

@niieani
niieani / throttle-and-debounce.sh
Last active December 11, 2023 15:39
throttle and debounce commands in bash
#!/usr/bin/env bash
declare -i last_called=0
declare -i throttle_by=2
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called >= $throttle_by))
then
"$@"