z-debouncer
v1.0.0
Published
Lightweight debounce functionality
Readme
Welcome to z-debouncer 🏓
Simple JS debounce functionality
🏠 Homepage
Install
npm install z-debouncerUsage
const debouncer = require('z-debouncer');
let debounce = debouncer.create();
debounce.add(() => console.log('Hello World'));
debounce.add(() => console.log('Hello World 2'));
debounce.add(() => console.log('Hello World 3'));
// Hello World 3Event Handling
<button id="someButton" onclick="buttonEvent()">Click Me</button>let debounce = debouncer.create();
function buttonEvent() {
debounce.add(() => console.log('Only run once!'));
}API
debouncer.create(delay)
Creates a new instance of Debouncer.
| Parameter | Type | Description | |-----------|------|-------------| | delay | number | Millisecond delay for before running. Defaults to 1000 |
[instance].add(func)
Add a function call to the debounce stack, replacing any existing calls.
| Parameter | Type | Description | |-------|------|-------------| | func | function | Function to run |
Author
👤 zachnology
- Github: @zachnology
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2021 Zack Gomez.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator
