DefinitelyTyped/types/just-throttle/just-throttle-tests.ts
Dominik Rowicki 6d7624e50f Create definition for just-throttle (#38707)
* Create definition for just-throttle

* Use more specific URL for the project

* Improve comments in tests slightly
2019-10-02 13:56:23 -07:00

12 lines
494 B
TypeScript

import throttle = require('just-throttle');
// returns a function that sets an interval but doesn't do anything else by
// default
throttle(() => 'foo', 200); // $ExpectType () => void
throttle(() => 'foo', 200, false); // $ExpectType () => void
// if third argument is true, the returned function will immediately apply the
// callback when called
throttle(() => 'foo', 200, true); // $ExpectType () => string
throttle((foo: string) => 42, 200, true); // $ExpectType (foo: string) => number