A tiny TypeScript library for debouncing functions.
npm install @yeger/debounce
A tiny TypeScript library for debouncing functions.
- ✨ Debounce any callback. Usefull for preventing flickering when using ResizeObserver.
- ⏱️ Optional delays for callback invocations.
- 🐭 Tiny.
``bashyarn
$ yarn add @yeger/debounce
Usage
`typescript
import { debounce } from '@yeger/debounce'// Take an existing function
function resize(): void {
// ...
}
// Debounce it using the library
const debouncedResize = debounce(() => resize())
// And use the debounced function
const resizeObserver = new ResizeObserver(debouncedResize)
`Optionally, a delay for the invocation of the debounced method can be passed.
`typescript
const debouncedResize = debounce(() => resize(), 200)
`Development
`bash
install dependencies
$ pnpm installbuild for production
$ pnpm buildlint project files
$ pnpm lintrun tests
$ pnpm test
``MIT - Copyright © Jan Müller