diff --git a/index.d.ts b/index.d.ts index ba87496..e11b258 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -export interface Options { +export type Options = { /** Number of concurrently pending promises returned by `mapper`. @@ -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. @@ -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'; @@ -42,7 +40,7 @@ export interface Options { ``` */ readonly signal?: AbortSignal; -} +}; type MaybePromise = T | Promise; diff --git a/index.test-d.ts b/index.test-d.ts index c4a1ae8..81b560f 100644 --- a/index.test-d.ts +++ b/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', diff --git a/package.json b/package.json index d2e77d6..f366784 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/readme.md b/readme.md index 44e2b2a..50cd4d9 100644 --- a/readme.md +++ b/readme.md @@ -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 @@ -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. @@ -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'; @@ -132,12 +130,6 @@ 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 @@ -145,5 +137,4 @@ The maintainers of p-map and thousands of other packages are working with Tideli - [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)