{"_id":"@cjser/p-map__v6_0_0","name":"@cjser/p-map__v6_0_0","dist-tags":{"latest":"6.0.0-cjser.2"},"versions":{"6.0.0-cjser.2":{"name":"@cjser/p-map__v6_0_0","version":"6.0.0-cjser.2","description":"Map over promises concurrently","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"require":"./dist-cjser/index.cjs","default":"./index.js"},"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","map","resolved","wait","collection","iterable","iterator","race","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"devDependencies":{"ava":"^5.2.0","delay":"^5.0.0","in-range":"^3.0.0","random-int":"^3.0.0","time-span":"^5.1.0","tsd":"^0.28.1","xo":"^0.54.1"},"main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"6.0.0","cjserVersion":2,"original":{"name":"p-map","version":"6.0.0","exports":"./index.js","repository":"sindresorhus/p-map","files":["index.js","index.d.ts"],"scripts":{"test":"xo && ava && tsd"}}},"_id":"@cjser/p-map__v6_0_0@6.0.0-cjser.2","gitHead":"0168e4aac54a1a9ca6f921419fa5ed9edb53ef4a","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-lF16DqCuK+XR1qQv+hgRsI8gG2AFQJEWkWVaSiRIRsjuYoCEvjPuMSmnKSKIV9eJ/rrct86AHzxn/Ph3syuDbg==","shasum":"09e32d0cc92633d0eebf5aa9f7e02682b8f72165","tarball":"https://registry.npmjs.org/@cjser/p-map__v6_0_0/-/p-map__v6_0_0-6.0.0-cjser.2.tgz","fileCount":6,"unpackedSize":22059,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDnjrVdEIGXf86Qh9LzvvJ82bpY1MBkpeEfxoCYWiKMvgIgFaKcXzTRMY+d/BGa35W336aOuQ6dlLVDGu+eyL1aLjA="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/p-map__v6_0_0_6.0.0-cjser.2_1778130874644_0.6506208554331865"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T05:14:34.549Z","6.0.0-cjser.2":"2026-05-07T05:14:34.779Z","modified":"2026-05-07T05:14:34.973Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Map over promises concurrently","keywords":["promise","map","resolved","wait","collection","iterable","iterator","race","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","readme":"# p-map\n\n> Map over promises concurrently\n\nUseful when you need to run promise-returning & async functions multiple times with different inputs concurrently.\n\nThis is different from `Promise.all()` in that you can control the concurrency and also decide whether or not to stop iterating when there's an error.\n\n## Install\n\n```sh\nnpm install p-map\n```\n\n## Usage\n\n```js\nimport pMap from 'p-map';\nimport got from 'got';\n\nconst sites = [\n\tgetWebsiteFromUsername('sindresorhus'), //=> Promise\n\t'https://avajs.dev',\n\t'https://github.com'\n];\n\nconst mapper = async site => {\n\tconst {requestUrl} = await got.head(site);\n\treturn requestUrl;\n};\n\nconst result = await pMap(sites, mapper, {concurrency: 2});\n\nconsole.log(result);\n//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']\n```\n\n## API\n\n### pMap(input, mapper, options?)\n\nReturns a `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.\n\n#### input\n\nType: `AsyncIterable<Promise<unknown> | unknown> | Iterable<Promise<unknown> | unknown>`\n\nSynchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item.\n\nAsynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.\n\n#### mapper(element, index)\n\nType: `Function`\n\nExpected to return a `Promise` or value.\n\n#### options\n\nType: `object`\n\n##### concurrency\n\nType: `number` *(Integer)*\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nNumber of concurrently pending promises returned by `mapper`.\n\n##### stopOnError\n\nType: `boolean`\\\nDefault: `true`\n\nWhen `true`, the first mapper rejection will be rejected back to the consumer.\n\nWhen `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.\n\nCaveat: 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.\n\n##### signal\n\nType: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nYou can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).\n\n```js\nimport pMap from 'p-map';\nimport delay from 'delay';\n\nconst abortController = new AbortController();\n\nsetTimeout(() => {\n\tabortController.abort();\n}, 500);\n\nconst mapper = async value => value;\n\nawait pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});\n// Throws AbortError (DOMException) after 500 ms.\n```\n\n### pMapSkip\n\nReturn this value from a `mapper` function to skip including the value in the returned array.\n\n```js\nimport pMap, {pMapSkip} from 'p-map';\nimport got from 'got';\n\nconst sites = [\n\tgetWebsiteFromUsername('sindresorhus'), //=> Promise\n\t'https://avajs.dev',\n\t'https://example.invalid',\n\t'https://github.com'\n];\n\nconst mapper = async site => {\n\ttry {\n\t\tconst {requestUrl} = await got.head(site);\n\t\treturn requestUrl;\n\t} catch {\n\t\treturn pMapSkip;\n\t}\n};\n\nconst result = await pMap(sites, mapper, {concurrency: 2});\n\nconsole.log(result);\n//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']\n```\n\n## Related\n\n- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency\n- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently\n- [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently\n- [p-props](https://github.com/sindresorhus/p-props) - Like `Promise.all()` but for `Map` and `Object`\n- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially\n- [More…](https://github.com/sindresorhus/promise-fun)\n\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/p-map\n","readmeFilename":"readme.md","_rev":"1-2cca5a9a30c3d789f7e23c5fc6bc0a80"}