diff --git a/debounce/debounce-tests.ts b/debounce/debounce-tests.ts new file mode 100644 index 0000000000..947fbcdae5 --- /dev/null +++ b/debounce/debounce-tests.ts @@ -0,0 +1,14 @@ +/// + +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); diff --git a/debounce/debounce.d.ts b/debounce/debounce.d.ts new file mode 100644 index 0000000000..7aa24601a7 --- /dev/null +++ b/debounce/debounce.d.ts @@ -0,0 +1,11 @@ +// Type definitions for compose-function +// Project: https://github.com/component/debounce +// Definitions by: 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(f: A, interval?: number, immediate?: boolean): A + export default f; +}