mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-10 12:10:18 +00:00
14
debounce/debounce-tests.ts
Normal file
14
debounce/debounce-tests.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/// <reference path="debounce.d.ts" />
|
||||
|
||||
import debounce from "debounce";
|
||||
|
||||
const doThings = () => 1;
|
||||
|
||||
debounce(function(){ doThings(); })();
|
||||
|
||||
debounce(function(){ doThings(); }, 1000)();
|
||||
|
||||
debounce(function(a: string){ doThings(); }, 1000)("foo");
|
||||
|
||||
// Immediate true should return the value
|
||||
const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
|
||||
11
debounce/debounce.d.ts
vendored
Normal file
11
debounce/debounce.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Type definitions for compose-function
|
||||
// Project: https://github.com/component/debounce
|
||||
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "debounce" {
|
||||
// Overload on boolean constants would allow us to narrow further,
|
||||
// but it is not implemented for TypeScript yet
|
||||
function f<A extends Function>(f: A, interval?: number, immediate?: boolean): A
|
||||
export default f;
|
||||
}
|
||||
Reference in New Issue
Block a user