# p-min-delay

> Delay a promise a minimum amount of time

Latest version **4.2.0** (published 2025-09-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install p-min-delay
pnpm add p-min-delay
yarn add p-min-delay
bun add p-min-delay
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2025-09-25 |
| First published | 2016-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 177 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | promise, delay, minimum, min, resolve, stall, defer, wait, timeout, settimeout, event, loop, next, tick, delay, async, await, promises, bluebird |

## Links

- npm: https://www.npmjs.com/package/p-min-delay
- Repository: https://github.com/sindresorhus/p-min-delay
- Homepage: https://github.com/sindresorhus/p-min-delay#readme
- Issues: https://github.com/sindresorhus/p-min-delay/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/p-min-delay

## Dependencies (1)

- [yoctodelay](https://npm.io/package/yoctodelay.md) ^2.0.0

## 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

- 4.2.0 (latest) — 2025-09-25
- 4.1.1 — 2025-09-08
- 4.1.0 — 2025-02-24
- 4.0.2 — 2022-12-25
- 4.0.1 — 2021-08-19
- 4.0.0 — 2021-05-03
- 3.2.0 — 2021-01-02
- 3.1.0 — 2019-04-03
- 3.0.0 — 2019-03-18
- 2.0.0 — 2016-11-22
- 1.0.0 — 2016-11-20

## README

# p-min-delay

> Delay a promise a minimum amount of time

While the [`delay`](https://github.com/sindresorhus/delay) module delays the promise a specified amount of time and then resolves it, this module ensures the promise resolves after the specified amount of time.

Useful when you have a promise that may settle immediately or may take some time, and you want to ensure it doesn't settle too fast. For example, if you want to show a loading indicator for at least 1 second (but longer if needed) to prevent a confusing flash in the UI.

## Install

```sh
npm install p-min-delay
```

## Usage

```js
import pMinDelay from 'p-min-delay';

// With a promise
const value = await pMinDelay(somePromise, 1000);
// Executed after minimum 1 second even if `somePromise` fulfills before that

// With a function
const delayedFunction = pMinDelay(async () => {
	const result = await fetch('/api/data');
	return result.json();
}, 1000);

// The returned function will ensure a minimum delay
const data = await delayedFunction();
// Executed after minimum 1 second even if the fetch completes before that
```

## API

### pMinDelay(input, minimumDelay, options?)

#### input

Type: `Promise | Function`

Promise to delay or function to wrap with a delay.

When a function is passed, `pMinDelay` returns a new function that wraps the original. Each call to the returned function will ensure the promise it returns takes at least the specified minimum delay to settle.

#### minimumDelay

Type: `number`

Time in milliseconds.

#### options

Type: `Object`

##### delayRejection

Type: `boolean`\
Default: `true`

Delay the rejection.

Turn this off if you want a rejected promise to fail fast.

## Related

- [delay](https://github.com/sindresorhus/delay) - Delay a promise a specified amount of time
- [p-immediate](https://github.com/sindresorhus/p-immediate) - Returns a promise resolved in the next event loop - think `setImmediate()`
- [p-timeout](https://github.com/sindresorhus/p-timeout) - Timeout a promise after a specified amount of time
- [More…](https://github.com/sindresorhus/promise-fun)

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