# w2t

> Tiny asynchronous action timer.

Latest version **3.0.2** (published 2022-03-16) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2022-03-16 |
| First published | 2018-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | estrattonbailey |
| Maintainers | estrattonbailey |

## Links

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

## Recent versions

- 3.0.2 (latest) — 2022-03-16
- 3.0.1 — 2022-03-16
- 3.0.0 — 2022-03-16
- 2.0.2 — 2019-10-07
- 2.0.1 — 2019-10-07
- 2.0.0 — 2019-10-07
- 1.0.0 — 2019-06-04
- 0.0.2 — 2018-05-20
- 0.0.1 — 2018-05-20

## README

# w2t
Tiny asynchronous action timer. **150 bytes gzipped.**

### Install
```
npm i w2t --save
```

### What is this?
Sometimes UI actions feel more human if we delay them instead of allowing them to
be completed at computer time. `w2t` allows you to specify actions and a *minimum*
time for them to be completed before the `Promise` is resolved.

If your specified action(s) take longer than the minimum, `w2t` will wait for
all actions to complete before resolving.

# Usage
`w2t` is a thin wrapper around `Promise.all`, so the API is essentially the
same: resolved values are returned on an array, with order preserved.

Below, `w2t` will resolve `foo` and `baz`, but wait 500 ms before returning.
```javascript
import wait from 'w2t'

const foo = async () => 'bar'
const baz = async () => 'qux'

wait(500, [ foo, baz ]).then(([ resolvedFoo, resolvedBaz ]) => {
  console.log(resolvedFoo, resolveBaz) // 'bar qux'
})
```

If no actions are provided, `w2t` becomes useful as a "sleep" function.
```javascript
// do something

await wait(600)

// do something 600ms later
```

# Changelog
- `v2.0.0` - Typescript rewrite, add tests
- `v1.0.0` - initial release

### License
MIT License © [Eric Bailey](https://estrattonbailey.com)

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