Creates a debounced version of the given function which waits to execute until its last call within a given time period. Supports an option to prevent subsequent execution of the function after the first execution.
Script include creates global DebounceFunction
:
<script src="debounce-function.min.js"></script>
AMD:
<script src="debounce-function.min.js"></script>
<script>
define(['debounce-function'], function(DebounceFunction) {
// do something
})
</script>
CommonJS:
$ npm install debounce-function
var DebounceFunction = require('debounce-function')
DebounceFunction.get()
returns a new function that is the given function in a debounced wrapper.
var foo = function() {
console.log('foo')
}
// Get a debounced variant of `foo`
var debouncedFoo = DebounceFunction.get(foo, 100)
// Get a debounced variant of `foo`, set to execute only once
var debouncedFooOnlyOnce = DebounceFunction.get(foo, 100, true)
$ cd debounce-function
$ npm install
$ grunt install
$ grunt build
$ grunt test
# Build for release
$ grunt dist
Copyright (c) 2016 Greg Stallings. See LICENSE for details.