Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 22, 2023
1 parent df88787 commit ebb7c70
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
8 changes: 3 additions & 5 deletions index.d.ts
@@ -1,4 +1,4 @@
export interface Options {
export type Options = {
/**
Number of concurrently pending promises returned by `mapper`.
Expand All @@ -11,7 +11,7 @@ export interface Options {
/**
When `true`, the first mapper rejection will be rejected back to the consumer.
When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) containing all the errors from the rejected promises.
Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. [Issue #51](https://github.com/sindresorhus/p-map/issues/51) can be implemented for abort control.
Expand All @@ -22,8 +22,6 @@ export interface Options {
/**
You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
**Requires Node.js 16 or later.*
@example
```
import pMap from 'p-map';
Expand All @@ -42,7 +40,7 @@ export interface Options {
```
*/
readonly signal?: AbortSignal;
}
};

type MaybePromise<T> = T | Promise<T>;

Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
@@ -1,5 +1,5 @@
import {expectType, expectAssignable} from 'tsd';
import pMap, {Options, Mapper, pMapSkip} from './index.js';
import pMap, {type Options, type Mapper, pMapSkip} from './index.js';

const sites = [
'https://sindresorhus.com',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -41,12 +41,12 @@
"bluebird"
],
"devDependencies": {
"ava": "^4.1.0",
"ava": "^5.2.0",
"delay": "^5.0.0",
"in-range": "^3.0.0",
"random-int": "^3.0.0",
"time-span": "^5.0.0",
"tsd": "^0.19.1",
"xo": "^0.48.0"
"time-span": "^5.1.0",
"tsd": "^0.28.1",
"xo": "^0.54.1"
}
}
15 changes: 3 additions & 12 deletions readme.md
Expand Up @@ -8,8 +8,8 @@ This is different from `Promise.all()` in that you can control the concurrency a

## Install

```
$ npm install p-map
```sh
npm install p-map
```

## Usage
Expand Down Expand Up @@ -74,7 +74,7 @@ Default: `true`

When `true`, the first mapper rejection will be rejected back to the consumer.

When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) containing all the errors from the rejected promises.

Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. [Issue #51](https://github.com/sindresorhus/p-map/issues/51) can be implemented for abort control.

Expand All @@ -84,8 +84,6 @@ Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSign

You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).

*Requires Node.js 16 or later.*

```js
import pMap from 'p-map';
import delay from 'delay';
Expand Down Expand Up @@ -132,18 +130,11 @@ console.log(result);
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
```

## p-map for enterprise

Available as part of the Tidelift Subscription.

The maintainers of p-map and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-p-map?utm_source=npm-p-map&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

## Related

- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
- [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently
- [p-props](https://github.com/sindresorhus/p-props) - Like `Promise.all()` but for `Map` and `Object`
- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially
- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
- [More…](https://github.com/sindresorhus/promise-fun)

0 comments on commit ebb7c70

Please sign in to comment.