mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #31437 from pash90/master
Added type definitions for flushable
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* The usage example is taken directly
|
||||
* from the package's README
|
||||
*/
|
||||
|
||||
import flushable from 'flushable';
|
||||
|
||||
// prints a message to the console after 1 second
|
||||
const operation = flushable(flushed => {
|
||||
const result = `I completed ${flushed ? 'early' : 'on time'}`;
|
||||
}, 1000);
|
||||
|
||||
// true if the callback has not been executed
|
||||
operation.pending();
|
||||
|
||||
// stops the callback from being executed
|
||||
operation.cancel();
|
||||
|
||||
// immediately executes the callback
|
||||
operation.flush();
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for flushable 1.0
|
||||
// Project: https://github.com/petegleeson/flushable#readme
|
||||
// Definitions by: Parth Mehta <https://github.com/pash90>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type FlushableOnCompleteHandler = (flushed: boolean) => any;
|
||||
|
||||
export interface FlushableOperation {
|
||||
/** Returns whether or not the callback has been executed */
|
||||
pending: () => boolean;
|
||||
/** Stops the callback from being executed */
|
||||
cancel: () => void;
|
||||
/** Immediately executes the callback */
|
||||
flush: () => void;
|
||||
}
|
||||
|
||||
export default function flushable(
|
||||
onComplete: FlushableOnCompleteHandler,
|
||||
delay: number
|
||||
): FlushableOperation;
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "flushable-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user