# p-settle

> Settle promises concurrently and get their fulfillment value or rejection reason with optional limited concurrency

Latest version **5.2.1** (published 2026-04-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install p-settle
pnpm add p-settle
yarn add p-settle
bun add p-settle
```

## Health

**Score 65/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.2.1 |
| Published | 2026-04-11 |
| First published | 2016-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 96 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | promise, settle, settled, resolved, iterator, fulfill, reject, fulfilled, rejected, reflect, inspect, error, async, await, promises, concurrently, concurrency, parallel, bluebird |

## Links

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

## Dependencies (2)

- [p-limit](https://npm.io/package/p-limit.md) ^4.0.0
- [p-reflect](https://npm.io/package/p-reflect.md) ^3.1.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

- 5.2.1 (latest) — 2026-04-11
- 5.2.0 — 2025-09-10
- 5.1.1 — 2023-10-09
- 5.1.0 — 2022-07-27
- 5.0.0 — 2021-08-13
- 4.1.1 — 2020-05-29
- 4.1.0 — 2020-05-21
- 4.0.1 — 2020-03-29
- 4.0.0 — 2020-03-05
- 3.1.0 — 2019-04-03
- 3.0.0 — 2019-03-19
- 2.1.0 — 2018-03-31
- 2.0.0 — 2016-11-26
- 1.1.0 — 2016-11-25
- 1.0.0 — 2016-10-21

## README

# p-settle

> Settle promises concurrently and get their fulfillment value or rejection reason with optional limited concurrency

## Install

```sh
npm install p-settle
```

## Usage

```js
import fs from 'node:fs/promises';
import pSettle from 'p-settle';

const files = [
	'a.txt',
	'b.txt' // Doesn't exist
].map(filename => fs.readFile(filename, 'utf8'));

console.log(await pSettle(files));
/*
[
	{
		status: 'fulfilled',
		value: '🦄',
		isFulfilled: true,
		isRejected: false,
	},
	{
		status: 'rejected',
		reason: [Error: ENOENT: no such file or directory, open 'b.txt'],
		isFulfilled: false,
		isRejected: true,
	}
]
*/
```

With a `mapper` function:

```js
import fs from 'node:fs/promises';
import pSettle from 'p-settle';

const files = ['a.txt', 'b.txt']; // Filenames

console.log(await pSettle(files, {
	mapper: filename => fs.readFile(filename, 'utf8'),
	concurrency: 2
}));
/*
[
	{
		status: 'fulfilled',
		value: '🦄',
		isFulfilled: true,
		isRejected: false,
	},
	{
		status: 'rejected',
		reason: [Error: ENOENT: no such file or directory, open 'b.txt'],
		isFulfilled: false,
		isRejected: true,
	}
]
*/
```

## API

### pSettle(array, options?)

Returns a `Promise<object[]>` that is fulfilled when all promises from the `array` argument are settled.

The objects in the array have the following properties:

- `status` *(`'fulfilled'` or `'rejected'`, depending on how the promise resolved)*
- `value` or `reason` *(Depending on whether the promise fulfilled or rejected)*
- `isFulfilled`
- `isRejected`

#### array

Type: `Array<ValueType | PromiseLike<ValueType> | ((...args: any[]) => PromiseLike<ValueType>)>`

The array can contain a mix of any value, promise, and async function. Promises are awaited. Async functions are executed and awaited. The `concurrency` option only works for elements that are async functions.

When using the `mapper` option, `array` can be of any type since the `mapper` function will transform each element.

#### options

Type: `object`

##### concurrency

Type: `number` (Integer)\
Default: `Infinity`\
Minimum: `1`

The number of concurrently pending promises.

**Note:** This only limits concurrency for elements that are async functions, not promises. When using the `mapper` option, concurrency applies to the mapped functions.

##### mapper

Type: `Function`

Function which is called for every item in `array`. Expected to return a promise or value.

The mapper function receives two arguments:
- `element` - The current element being processed
- `index` - The index of the element in the source array

When provided, the `mapper` function transforms each element in the array before settling it. This allows you to work with arrays of any type of data.

### isFulfilled(object)

This is a type guard for TypeScript users.

This is useful since `await pSettle(promiseArray)` always returns a `PromiseResult[]`. This function can be used to determine whether `PromiseResult` is `PromiseFulfilledResult` or `PromiseRejectedResult`.

### isRejected(object)

This is a type guard for TypeScript users.

This is useful since `await pSettle(promiseArray)` always returns a `PromiseResult[]`. This function can be used to determine whether `PromiseResult` is `PromiseRejectedResult` or `PromiseFulfilledResult`.

## Related

- [p-reflect](https://github.com/sindresorhus/p-reflect) - Make a promise always fulfill with its actual fulfillment value or rejection reason
- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
- [More…](https://github.com/sindresorhus/promise-fun)

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