@types/throttle-debounce
Advanced tools
Comparing version 2.1.0 to 4.0.0
@@ -1,4 +0,4 @@ | ||
// Type definitions for throttle-debounce 2.1 | ||
// Type definitions for throttle-debounce 4.0 | ||
// Project: https://github.com/niksy/throttle-debounce | ||
// Definitions by: Marek Buchar <https://github.com/czbuchi>, Frank Li <https://github.com/franklixuefei>, Thomas Oddsund <https://github.com/oddsund> | ||
// Definitions by: Marek Buchar <https://github.com/czbuchi>, Frank Li <https://github.com/franklixuefei>, Thomas Oddsund <https://github.com/oddsund>, Seiya <https://github.com/seiyab> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -12,5 +12,15 @@ | ||
export type throttle<T> = T & Cancel; | ||
export type debounce<T> = throttle<T>; | ||
interface NoReturn<T extends (...args: any[]) => any> { | ||
(...args: Parameters<T>): void; | ||
} | ||
export type throttle<T extends (...args: any[]) => any> = NoReturn<T> & Cancel; | ||
export type debounce<T extends (...args: any[]) => any> = throttle<T>; | ||
interface ThrottleOptions { | ||
noTrailing?: boolean; | ||
noLeading?: boolean; | ||
debounceMode?: boolean; | ||
} | ||
/** | ||
@@ -24,9 +34,2 @@ * Throttle execution of a function. Especially useful for rate limiting | ||
* | ||
* @param noTrailing | ||
* If noTrailing is true, callback will only execute every `delay` milliseconds | ||
* while the throttled-function is being called. If noTrailing is false or | ||
* unspecified, callback will be executed one final time fter the last | ||
* throttled-function call. (After the throttled-function has not been called | ||
* for `delay` milliseconds, the internal counter is reset) | ||
* | ||
* @param callback | ||
@@ -37,30 +40,19 @@ * A function to be executed after delay milliseconds. The `this` context and | ||
* | ||
* @param debounceMode If `debounceMode` is true (at begin), schedule | ||
* `callback` to execute after `delay` ms. If `debounceMode` is false (at end), | ||
* schedule `callback` to execute after `delay` ms. | ||
* @param options | ||
* An object to configure options. | ||
* | ||
* @return | ||
* A new, throttled, function. | ||
*/ | ||
export function throttle<T extends (...args: any[]) => any>( | ||
delay: number, | ||
noTrailing: boolean, | ||
callback: T, | ||
debounceMode?: boolean | ||
): throttle<T>; | ||
/** | ||
* Throttle execution of a function. Especially useful for rate limiting | ||
* execution of handlers on events like resize and scroll. | ||
* @param options.noTrailing | ||
* Optional, defaults to false. If noTrailing is true, callback will only execute | ||
* every `delay` milliseconds while the throttled-function is being called. If | ||
* noTrailing is false or unspecified, callback will be executed one final time | ||
* after the last throttled-function call. (After the throttled-function has not | ||
* been called for `delay` milliseconds, the internal counter is reset) | ||
* | ||
* @param delay | ||
* A zero-or-greater delay in milliseconds. For event callbacks, values around | ||
* 100 or 250 (or even higher) are most useful. | ||
* @param options.noLeading | ||
* Optional, defaults to false. If noLeading is false, the first throttled-function | ||
* call will execute callback immediately. If noLeading is true, the first the | ||
* callback execution will be skipped. It should be noted that callback will never | ||
* executed if both noLeading = true and noTrailing = true. | ||
* | ||
* @param callback | ||
* A function to be executed after delay milliseconds. The `this` context and | ||
* all arguments are passed through, as-is, to `callback` when the | ||
* throttled-function is executed. | ||
* | ||
* @param debounceMode If `debounceMode` is true (at begin), schedule | ||
* @param options.debounceMode If `debounceMode` is true (at begin), schedule | ||
* `callback` to execute after `delay` ms. If `debounceMode` is false (at end), | ||
@@ -75,3 +67,3 @@ * schedule `callback` to execute after `delay` ms. | ||
callback: T, | ||
debounceMode?: boolean | ||
options?: ThrottleOptions, | ||
): throttle<T>; | ||
@@ -103,7 +95,3 @@ | ||
*/ | ||
export function debounce<T extends (...args: any[]) => any>( | ||
delay: number, | ||
atBegin: boolean, | ||
callback: T | ||
): debounce<T>; | ||
export function debounce<T extends (...args: any[]) => any>(delay: number, atBegin: boolean, callback: T): debounce<T>; | ||
@@ -127,5 +115,2 @@ /** | ||
*/ | ||
export function debounce<T extends (...args: any[]) => any>( | ||
delay: number, | ||
callback: T | ||
): debounce<T>; | ||
export function debounce<T extends (...args: any[]) => any>(delay: number, callback: T): debounce<T>; |
{ | ||
"name": "@types/throttle-debounce", | ||
"version": "2.1.0", | ||
"version": "4.0.0", | ||
"description": "TypeScript definitions for throttle-debounce", | ||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/throttle-debounce", | ||
"license": "MIT", | ||
@@ -21,6 +22,11 @@ "contributors": [ | ||
"githubUsername": "oddsund" | ||
}, | ||
{ | ||
"name": "Seiya", | ||
"url": "https://github.com/seiyab", | ||
"githubUsername": "seiyab" | ||
} | ||
], | ||
"main": "", | ||
"types": "index", | ||
"types": "index.d.ts", | ||
"repository": { | ||
@@ -33,4 +39,4 @@ "type": "git", | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "8adb54836c4a82286e9e06515968293d0b9ab6b8fd6502f6bdd327704fcd741a", | ||
"typeScriptVersion": "2.0" | ||
"typesPublisherContentHash": "6553922707bbe2109ba27cf9e79336f8fcf85ca6cacfbd468c52ee58a5b92343", | ||
"typeScriptVersion": "3.9" | ||
} |
@@ -8,6 +8,6 @@ # Installation | ||
# Details | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/throttle-debounce | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/throttle-debounce. | ||
Additional Details | ||
* Last updated: Mon, 26 Aug 2019 15:15:52 GMT | ||
### Additional Details | ||
* Last updated: Mon, 11 Apr 2022 19:01:24 GMT | ||
* Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by Marek Buchar <https://github.com/czbuchi>, Frank Li <https://github.com/franklixuefei>, and Thomas Oddsund <https://github.com/oddsund>. | ||
These definitions were written by [Marek Buchar](https://github.com/czbuchi), [Frank Li](https://github.com/franklixuefei), [Thomas Oddsund](https://github.com/oddsund), and [Seiya](https://github.com/seiyab). |
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
7334
0
102