# soonish

> Sometimes you just need to chill for a second.

Latest version **1.0.0** (published 2019-08-03) · ISC license · 0 weekly downloads

## Install

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

## 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 | 1.0.0 |
| Published | 2019-08-03 |
| First published | 2019-08-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | AdrianT |
| Maintainers | cptpackrat |
| Keywords | wait, delay, callback, promise, rate, limit |

## Links

- npm: https://www.npmjs.com/package/soonish
- Repository: https://gitlab.com/cptpackrat/soonish
- Issues: https://gitlab.com/cptpackrat/soonish/issues
- npm.io page: https://npm.io/package/soonish

## 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.0 (latest) — 2019-08-03

## README

Soonish
=======
[![npm version][npm-image]][npm-url]
[![pipeline status][pipeline-image]][pipeline-url]
[![coverage status][coverage-image]][coverage-url]
[![standard-js][standard-image]][standard-url]

Sometimes you just need to chill for a second.

## Installation
```
npm install soonish
```

## Usage

### soonish(min, max, [callback])
Execute the provided callback after a random delay between `min` and `max` milliseconds. If `callback` is omitted, a function will be returned that can be used in a promise chain to achieve the same effect.

### soonish(max, [callback])
Execute the provided callback after a random delay between `max * 0.5` and `max` milliseconds. If `callback` is omitted, a function will be returned that can be used in a promise chain to achieve the same effect.

## Callback Example
```js
#!/usr/bin/env node
const soonish = require('soonish')
const debug = require('debug')('test')

debug('before')
soonish(0, 500, () => {
  debug('after first')
  soonish(500, () => {
    debug('after second')
  })
})
```
```
$ DEBUG=test ./example.js
  test before +0ms
  test after first +172ms
  test after second +282ms
```

## Promised Example
```js
#!/usr/bin/env node
const soonish = require('soonish')
const debug = require('debug')('test')

Promise.resolve()
  .then(() => { debug('before') })
  .then(soonish(0, 500))
  .then(() => { debug('after first') })
  .then(soonish(500))
  .then(() => { debug('after second') })
```
```
$ DEBUG=test ./example.js
  test before +0ms
  test after first +140ms
  test after second +309ms
```

Any values received will be passed through to the next promise in the chain:
```js
#!/usr/bin/env node
const soonish = require('soonish')

Promise.resolve('hello, world!')
  .then(soonish(500))
  .then(console.log)
```
```
$ ./example.js
hello, world!
```

[npm-image]: https://img.shields.io/npm/v/soonish.svg
[npm-url]: https://www.npmjs.com/package/soonish
[pipeline-image]: https://gitlab.com/cptpackrat/soonish/badges/master/pipeline.svg
[pipeline-url]: https://gitlab.com/cptpackrat/soonish/commits/master
[coverage-image]: https://gitlab.com/cptpackrat/soonish/badges/master/coverage.svg
[coverage-url]: https://gitlab.com/cptpackrat/soonish/commits/master
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[standard-url]: http://standardjs.com/

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