# ts-delay

> Typescript library to delay something by a minimum amount of time

Latest version **1.0.0** (published 2022-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-delay
pnpm add ts-delay
yarn add ts-delay
bun add ts-delay
```

## 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.0 |
| Published | 2022-11-23 |
| First published | 2022-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | indece UG |
| Maintainers | indece |

## Links

- npm: https://www.npmjs.com/package/ts-delay
- Repository: https://github.com/indece-official/ts-delay
- Homepage: https://github.com/indece-official/ts-delay#readme
- Issues: https://github.com/indece-official/ts-delay/issues
- npm.io page: https://npm.io/package/ts-delay

## Recent versions

- 1.0.0 (latest) — 2022-11-23

## README

# TS-Delay
Typescript library to delay something by a minimum amount of time

## Installation
```
npm install --save ts-delay
```

or 

```
yarn add ts-delay
```

## Examples
### Delay

```
import { Delay } from 'ts-delay';

async function main ( )
{
    console.log('Checking for updates ...');

    const delay = new Delay(1000);

    // This function finishes fast, but the user thinks id does nothing
    // if it doesn't take a minimum amount of time. But if the function
    // takes longer than usual, we don't want the user to have to wait
    // additional time....
    await checkForUpdates();

    // Wait 1000ms minus the time that already passed
    await delay.sleep();

    console.log('Finished checking for updates.');
}
```

### sleep

```
import { sleep } from 'ts-delay';

function async main ( )
{
    console.log('Running ...');

    await sleep(1000);

    console.log('Finished after 1s.');
}
```

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