DefinitelyTyped/types/flushable/flushable-tests.ts
2019-03-12 09:35:43 -07:00

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();