# flushable

> A flushable timeout function

Latest version **1.0.0** (published 2018-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install flushable
pnpm add flushable
yarn add flushable
bun add flushable
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-08-10 |
| First published | 2018-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/flushable) |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 189.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Peter Gleeson |
| Maintainers | petegleeson |

## Links

- npm: https://www.npmjs.com/package/flushable
- Repository: https://github.com/petegleeson/flushable
- Homepage: https://github.com/petegleeson/flushable#readme
- Issues: https://github.com/petegleeson/flushable/issues
- npm.io page: https://npm.io/package/flushable

## Recent versions

- 1.0.0 (latest) — 2018-08-10

## README

# flushable

`flushable` is useful in situations where you want to schedule a future operation that might be executed immediately or cancelled. Think `setTimeout` with a way of executing the callback immediately.

## Installation

```
yarn add flushable
```

## Usage

Create a pending operation by passing `flushable` a callback function and a delay. It returns an object that can be used to check the status of the operation, cancel the operation or execute the operation immediately.

```js
import flushable from "flushable";

// prints a message to the console after 1 second
const operation = flushable(flushed => {
  console.log(`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();
```

## Reference

```js
type Flushable = (
  (flushed: boolean) => any,
  delay: number
) => {
  cancel: () => void,
  flush: () => void,
  pending: () => boolean
};
```

---
_Source: https://npm.io/package/flushable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
