mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
21 lines
475 B
TypeScript
21 lines
475 B
TypeScript
/**
|
|
* The usage example is taken directly
|
|
* from the package's README
|
|
*/
|
|
|
|
import flushable = require('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();
|