mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
committed by
John-David Dalton
parent
f5ea579db3
commit
6ad829fa90
@@ -51,6 +51,9 @@ import isObject from './isObject.js'
|
||||
*
|
||||
* // Cancel the trailing debounced invocation.
|
||||
* jQuery(window).on('popstate', debounced.cancel)
|
||||
*
|
||||
* // Check for pending invocations.
|
||||
* const status = debounced.pending() ? "Pending…" : "Ready"
|
||||
*/
|
||||
function debounce(func, wait, options) {
|
||||
let lastArgs,
|
||||
@@ -148,6 +151,10 @@ function debounce(func, wait, options) {
|
||||
function flush() {
|
||||
return timerId === undefined ? result : trailingEdge(Date.now())
|
||||
}
|
||||
|
||||
function pending() {
|
||||
return timerId !== undefined
|
||||
}
|
||||
|
||||
function debounced(...args) {
|
||||
const time = Date.now()
|
||||
@@ -174,6 +181,7 @@ function debounce(func, wait, options) {
|
||||
}
|
||||
debounced.cancel = cancel
|
||||
debounced.flush = flush
|
||||
debounced.pending = pending
|
||||
return debounced
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user