Merge pull request #31437 from pash90/master

Added type definitions for flushable
This commit is contained in:
Nathan Shively-Sanders
2018-12-17 09:24:25 -08:00
committed by GitHub
4 changed files with 57 additions and 0 deletions
+20
View File
@@ -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();
+20
View File
@@ -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;
+16
View File
@@ -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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }