diff --git a/debounce.js b/debounce.js index a69689e..adebbd6 100644 --- a/debounce.js +++ b/debounce.js @@ -15,5 +15,6 @@ export default (action, delay=1e3) => { func.cancel() return action(...args) } + Object.defineProperty(func, "running", {get() {return Boolean(timeout)}}) return func } diff --git a/page/debounce.html b/page/debounce.html index 789380b..40af18a 100644 --- a/page/debounce.html +++ b/page/debounce.html @@ -41,12 +41,14 @@
- The returned wrapper function has two methods: + The returned wrapper function has the following methods and properties:
cancel()
now(...)
running
true
if there is a timeout currently running, false
otherwise.