debouncy
Yet another debounce implementation with 0 dependencies
Install
npm i --save debouncy
Usage
var debouncy = ;
signature
:Function
- fnToDebounce: Function The function to debounce
- threshold: Number
The number of milliseconds before actually executing the
fnToDebounce
since the last call to the debounced function. - ctx: Object The this object inside the debounced function. If none specified will try to use the ctx of the invocator.
- immediate: Boolean If true, the function will be executed on the leading edge.
Example
var debouncy = ; var debouncedFn = ;;// after 200ms// output: I am calledvar ctx = name: 'some obj';var debouncedFn = ;;// after 200ms// output: I am called from some obj var debouncedFn = ;;// immediately// output: I am called// other calls will have to wait 200ms before the last execution