mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Create definition for just-throttle (#38707)
* Create definition for just-throttle * Use more specific URL for the project * Improve comments in tests slightly
This commit is contained in:
parent
115ed66c06
commit
6d7624e50f
10
types/just-throttle/index.d.ts
vendored
Normal file
10
types/just-throttle/index.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
// Type definitions for just-throttle 1.1
|
||||
// Project: https://github.com/angus-c/just/tree/master/packages/function-throttle
|
||||
// Definitions by: Dominik Rowicki <https://github.com/papermana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
declare function throttle(fn: (...args: unknown[]) => unknown, interval: number, callFirst?: false): () => void;
|
||||
declare function throttle<T>(fn: T, interval: number, callFirst?: true): T;
|
||||
|
||||
export = throttle;
|
||||
11
types/just-throttle/just-throttle-tests.ts
Normal file
11
types/just-throttle/just-throttle-tests.ts
Normal file
@ -0,0 +1,11 @@
|
||||
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
|
||||
23
types/just-throttle/tsconfig.json
Normal file
23
types/just-throttle/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"just-throttle-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/just-throttle/tslint.json
Normal file
1
types/just-throttle/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user