Package Exports
- just-debounce
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (just-debounce) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
just-debounce
just a basic denounce function
Why?
I searched npm and the first 3 pages of results for "debounce" did not have a small corectly implemented version of debounce
Usage
arguments
fn: the function to debouncedelay: deboucne delay in msat_start:if true, the function will be called at the begining of the delay rather than the endguarantee: ensures the time before the next call thfnis not greater
than the delay perior.
var db = require('just-debounce')
var debounced = db(function(v) {console.log(v)}, 100)
debounced('hi')
debounced('hi')
// logs 'hi' once after 100msvar db = require('just-debounce')
var debounced = db(function(v) {console.log(v)}, 100, true)
debounced('hi')
debounced('hi')
// logs 'hi' once right away, but not a second time. calling after 100ms will log againvar db = require('just-debounce')
var debounced = db(function(v) {console.log(v)}, 100, false, true)
debounced('hi')
setTimeout(function() {debounced('hi2')}, 80)
// logs 'hi2' once 100ms after the first call to debounced