# promise-resolve-timeout

> Create a Promise which will resolve with the provided value after a timeout.

Latest version **2.0.1** (published 2025-01-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-resolve-timeout
pnpm add promise-resolve-timeout
yarn add promise-resolve-timeout
bun add promise-resolve-timeout
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2025-01-12 |
| First published | 2019-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | fabiospampinato |
| Keywords | promise, resolve, timeout |

## Links

- npm: https://www.npmjs.com/package/promise-resolve-timeout
- Repository: https://github.com/fabiospampinato/promise-resolve-timeout
- Homepage: https://github.com/fabiospampinato/promise-resolve-timeout#readme
- Issues: https://github.com/fabiospampinato/promise-resolve-timeout/issues
- npm.io page: https://npm.io/package/promise-resolve-timeout

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2025-01-12
- 2.0.0 — 2022-04-07
- 1.2.1 — 2020-03-22
- 1.2.0 — 2019-08-28
- 1.1.0 — 2019-08-27
- 1.0.0 — 2019-08-27

## README

# Promise Resolve Timeout

Create a Promise which will resolve with the provided value after a timeout.

## Install

```sh
npm install promise-resolve-timeout
```

## Usage

If the passed value is a function it will be called and its return value will be the resolved value, otherwise the passed value is the resolved value.

```ts
import resolveTimeout from 'promise-resolve-timeout';

// Defaulting to a default value when racing promises

Promise.race ([
  resolveTimeout ( 1000, false ), // Resolving after 1000ms
  resolveTimeout ( 5000, () => 'foo' ), // Resolving after 5000ms
  new Promise ( () => {
    // Something...
  });
]);

// Delaying

resolveTimeout ( 1000 ) // Waiting 1000ms
  .then ( () => {
    // Something...
  });
```

## License

MIT © Fabio Spampinato

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