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 @@

Methods

- The returned wrapper function has two methods: + The returned wrapper function has the following methods and properties:

cancel()
Cancels the running timeout without calling the target function.
now(...)
Cancels the running timeout and calls the target function immediately.
+
running
+
true if there is a timeout currently running, false otherwise.