# waituntil2

> Execute a task now and wait until a time interval to execute another task.

Latest version **1.0.2** (published 2020-05-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-06 |
| First published | 2020-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bisvarup Mukherjee |
| Maintainers | bisvarup |
| Keywords | once, function, wait, until, timer, function timer |

## Links

- npm: https://www.npmjs.com/package/waituntil2
- Repository: https://github.com/bisho1995/waituntil
- Issues: https://github.com/bisho1995/waituntil/issues
- npm.io page: https://npm.io/package/waituntil2

## Dependencies (2)

- [once](https://npm.io/package/once.md) ^1.4.0
- [wrappy](https://npm.io/package/wrappy.md) ^1.0.2

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-05-06
- 1.0.1 — 2020-05-06
- 1.0.0 — 2020-05-06

## README

# waituntil

Execute a task now and wait until a time interval to execute another task.

Suppose you need to show a snackbar message to a user after getting the API response from the server. After 5 seconds you need to redirect the user to the target route given by the API. You can solve this problem easily using this module.

## Installation

`npm i waituntil`

## Usage

### Basic usage

```
const waituntil = require('waituntil2')

const delayedTask = waituntil(()=>{ console.log("I will be running immediately when executed") }, (msg)=>{ console.log("I will run after 5 seconds and print this message ",msg) }, 5000 )

delayedTask("I am awesome")
```

The output is going to be

```
I will be running immediately when executed
```

and after 5 seconds

```
I will run after 5 seconds and print this message I am awesome
```

### Execute Once

Execute the function only once by passing the `executeOnce` flag as true

```
const waituntil = require('waituntil2')

const delayedTask = waituntil(()=>{ console.log("I will be running immediately when executed") }, (msg)=>{ console.log("I will run after 5 seconds and print this message",msg) }, 5000, true )

delayedTask("I am awesome")
delayedTask("I am awesome")
```

The output is going to be

```
I will be running immediately when executed
I will run after 5 seconds and print this message I am awesome
```

Note that although delayedTask is called twice, the function will be executed only once.

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