Merge pull request #30969 from wcarson/debounce

Added flush() method to debounce package (see https://git.io/fpoYM)
This commit is contained in:
Nathan Shively-Sanders 2018-12-03 09:05:50 -08:00 committed by GitHub
commit ead110d5f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -14,6 +14,9 @@ const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
const clearable = debounce(doThings);
clearable.clear();
const flushable = debounce(doThings);
flushable.flush();
// Intentionally asserts that the member variable has all the same benefits as the direct export.
// Eventually, if debounce stop supporting the CommonJS-only module calling (`require("debounce")(...)`),
// we can remove this and change the top import&require to `import { debounce } from "debounce";`.

View File

@ -1,13 +1,15 @@
// Type definitions for debounce 3.0
// Type definitions for debounce 1.2
// Project: https://github.com/component/debounce
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Wayne Carson <https://github.com/wcarson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace _debounce {
const debounce: typeof _debounce;
}
declare function _debounce<A extends Function>(f: A, interval?: number, immediate?: boolean): A & { clear(): void; };
declare function _debounce<A extends Function>(f: A, interval?: number, immediate?: boolean): A & { clear(): void; }
& { flush(): void };
export = _debounce;