@instructure/debounce
Advanced tools
Comparing version 10.4.1-snapshot-5 to 10.4.1-snapshot-6
@@ -6,3 +6,3 @@ # Change Log | ||
## [10.4.1-snapshot-5](https://github.com/instructure/instructure-ui/compare/v10.4.0...v10.4.1-snapshot-5) (2024-10-28) | ||
## [10.4.1-snapshot-6](https://github.com/instructure/instructure-ui/compare/v10.4.0...v10.4.1-snapshot-6) (2024-10-28) | ||
@@ -12,2 +12,3 @@ | ||
* docs screenreader alerts are no longer screendeader focusable ([c225853](https://github.com/instructure/instructure-ui/commit/c2258531aa377b698fe932012112704f1879b501)) | ||
* update license ([1c039d9](https://github.com/instructure/instructure-ui/commit/1c039d9cbf5a3ea99b59803ddde5c6c0b2d76ba5)) | ||
@@ -14,0 +15,0 @@ |
@@ -42,2 +42,4 @@ /* | ||
* on unmounted components. | ||
* For a cool explanation see https://css-tricks.com/debouncing-throttling-explained-examples/ | ||
* | ||
* @module debounce | ||
@@ -60,3 +62,3 @@ * | ||
let result; | ||
let lastCallTime; // TODO this should never be undefined | ||
let lastCallTime; | ||
let lastInvokeTime = 0; | ||
@@ -130,3 +132,4 @@ let timers = []; | ||
lastInvokeTime = 0; | ||
lastArgs = lastCallTime = lastThis = void 0; | ||
lastCallTime = 0; | ||
lastArgs = lastThis = void 0; | ||
} | ||
@@ -133,0 +136,0 @@ function flush() { |
@@ -49,2 +49,4 @@ "use strict"; | ||
* on unmounted components. | ||
* For a cool explanation see https://css-tricks.com/debouncing-throttling-explained-examples/ | ||
* | ||
* @module debounce | ||
@@ -67,3 +69,3 @@ * | ||
let result; | ||
let lastCallTime; // TODO this should never be undefined | ||
let lastCallTime; | ||
let lastInvokeTime = 0; | ||
@@ -137,3 +139,4 @@ let timers = []; | ||
lastInvokeTime = 0; | ||
lastArgs = lastCallTime = lastThis = void 0; | ||
lastCallTime = 0; | ||
lastArgs = lastThis = void 0; | ||
} | ||
@@ -140,0 +143,0 @@ function flush() { |
{ | ||
"name": "@instructure/debounce", | ||
"version": "10.4.1-snapshot-5", | ||
"version": "10.4.1-snapshot-6", | ||
"description": "A debounce util made by Instructure Inc.", | ||
@@ -25,3 +25,3 @@ "author": "Instructure, Inc. Engineering and Product Design", | ||
"devDependencies": { | ||
"@instructure/ui-babel-preset": "10.4.1-snapshot-5" | ||
"@instructure/ui-babel-preset": "10.4.1-snapshot-6" | ||
}, | ||
@@ -28,0 +28,0 @@ "dependencies": { |
@@ -31,6 +31,5 @@ /* | ||
export type Debounced = { | ||
(...args: unknown[]): unknown | ||
export type Debounced<F extends (...args: any) => any> = F & { | ||
cancel: () => void | ||
flush: () => void | ||
flush: () => ReturnType<F> | ||
} | ||
@@ -55,2 +54,4 @@ | ||
* on unmounted components. | ||
* For a cool explanation see https://css-tricks.com/debouncing-throttling-explained-examples/ | ||
* | ||
* @module debounce | ||
@@ -69,11 +70,11 @@ * | ||
*/ | ||
function debounce( | ||
func: (...args: any[]) => unknown, | ||
function debounce<F extends (...args: any) => any>( | ||
func: F, | ||
wait = 0, | ||
options: DebounceOptions = {} | ||
): Debounced { | ||
let lastArgs: unknown[] | undefined | ||
) { | ||
let lastArgs: unknown | undefined | ||
let lastThis: unknown | ||
let result: unknown | ||
let lastCallTime: number | undefined // TODO this should never be undefined | ||
let result: ReturnType<F> | ||
let lastCallTime: number | ||
let lastInvokeTime = 0 | ||
@@ -161,3 +162,4 @@ let timers: ReturnType<typeof setTimeout>[] = [] | ||
lastInvokeTime = 0 | ||
lastArgs = lastCallTime = lastThis = undefined | ||
lastCallTime = 0 | ||
lastArgs = lastThis = undefined | ||
} | ||
@@ -174,3 +176,3 @@ | ||
function debounced(...args: unknown[]) { | ||
function debounced(...args: any[]) { | ||
const time = Date.now() | ||
@@ -205,3 +207,3 @@ const isInvoking = shouldInvoke(time) | ||
return debounced | ||
return debounced as Debounced<F> | ||
} | ||
@@ -208,0 +210,0 @@ |
@@ -6,6 +6,5 @@ interface DebounceOptions { | ||
} | ||
export type Debounced = { | ||
(...args: unknown[]): unknown; | ||
export type Debounced<F extends (...args: any) => any> = F & { | ||
cancel: () => void; | ||
flush: () => void; | ||
flush: () => ReturnType<F>; | ||
}; | ||
@@ -29,2 +28,4 @@ /** | ||
* on unmounted components. | ||
* For a cool explanation see https://css-tricks.com/debouncing-throttling-explained-examples/ | ||
* | ||
* @module debounce | ||
@@ -43,5 +44,5 @@ * | ||
*/ | ||
declare function debounce(func: (...args: any[]) => unknown, wait?: number, options?: DebounceOptions): Debounced; | ||
declare function debounce<F extends (...args: any) => any>(func: F, wait?: number, options?: DebounceOptions): Debounced<F>; | ||
export default debounce; | ||
export { debounce }; | ||
//# sourceMappingURL=debounce.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147071
675