I found that debounced function was called at the first time and never be called again
If I use sleepSync, a sync version of sleep provided by Bun runtime.
import { sleepSync } from "bun";
import _ from 'lodash'
let count = 0
const debouncedFn = _.debounce(() => {
count++
console.log('>>> debouncedFn invoked, count:', count)
}, 1000, {
leading: true,
})
for(let i = 0; i < 10; i++) {
console.log('#', i)
debouncedFn()
sleepSync(2000)
}