{"_id":"@brandonxiang/p-map","_rev":"2-ec107b3b38199dd041894bdd3735ed07","name":"@brandonxiang/p-map","dist-tags":{"latest":"5.3.1"},"versions":{"5.3.0":{"name":"@brandonxiang/p-map","version":"5.3.0","description":"Map over promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-map.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"main":"dist/p-map.js","type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd","build":"bundt index.js"},"keywords":["promise","map","resolved","wait","collection","iterable","iterator","race","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"aggregate-error":"^4.0.0"},"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","in-range":"^3.0.0","random-int":"^3.0.0","time-span":"^5.0.0","tsd":"^0.14.0","xo":"^0.38.2","bundt":"^1.1.5"},"gitHead":"9f40622a3f367c2aa55f140e6b08b7b1fa337055","bugs":{"url":"https://github.com/sindresorhus/p-map/issues"},"homepage":"https://github.com/sindresorhus/p-map#readme","_id":"@brandonxiang/p-map@5.3.0","_nodeVersion":"14.15.0","_npmVersion":"7.21.0","dist":{"integrity":"sha512-pcPj2CydUJQdUPq3OOGnksP5Ytbv7b6Iu77eUh5jQIEM0pV3k0xk1bel7DsM8eOaInOPCS4y+P25X/76NINGgA==","shasum":"92d45438091cbac009635660f2634152a8e6479d","tarball":"https://registry.npmjs.org/@brandonxiang/p-map/-/p-map-5.3.0.tgz","fileCount":6,"unpackedSize":18739,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhofWvCRA9TVsSAnZWagAAR1AP/34udfepIvfyuL7PmjwI\n1CJgi/54IsbqZrmOkd+u0sj1sQ5PNGdaVflsj+jLzYn6dCnRk2QYrYU7BcvQ\nouyBpXAj07INtIP2Y87qnCJJhpzY0DvkIy1rIJkSuggfSMOBc5EzW209zdUn\no2gWLRj+sxCLMUV/w2/CsoXRVkph+PNeirvSsBIR2ev7EXxi4iciHXEA0E3c\n2koZH/1ywlvdYDGXEvvhcKK+/sbf86Dam8tFWt6dUssD2oPpXuiyvgp4gEOV\nW7QJ1xrxiiV9JuybO6WGsY0+5kbaZPN0qkpY7iFJ8CxboFHj9JQ+jb9R36Wi\nIgoNRs3/OSrLieRJJaI3XbyFV3E8ak7ixGijYOu87isvShWTCqEE+welCwB4\ntnCA3nXhF/sDmpLs83q4vEKSH2BiDFIR2VjkspgWBbzM7Aotskz+v+x1J3hA\nZfCsWyUj6+jI5OUAgUluR7LQu6HGXlqFE4aeHW/V6/NclgZMSm5xkJpsppue\nxV2wvUE7y7Eh1DNx6xYAcZSNuY9v5yPKjLgj1o2BO8YC2fkH66BvrscuUXG8\nFBzxdfOFGPzfaBhaYT3xTh5EezV5NkG15Xv4ZhigGJtns+RE3vVt2kKhN7/f\nBQTJLCCjauGLhLG7go2MVdTz8c3VMy+wG/IYQun2bVFPuEi0O3ZTp9wEO4nN\nx0MK\r\n=ipJ4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDa2B/M7xQBljaa3o0fPO72C78w6f1kViTQRMa1QVtVIQIhAJ24BIWoDfjDHLj+vXGdoOv9WlP1cSvS8lC5RNn4j40K"}]},"_npmUser":{"name":"brandonxiang","email":"1132500533@qq.com"},"directories":{},"maintainers":[{"name":"brandonxiang","email":"1132500533@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-map_5.3.0_1638004143128_0.22495890458206014"},"_hasShrinkwrap":false},"5.3.1":{"name":"@brandonxiang/p-map","version":"5.3.1","description":"Map over promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-map.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"main":"dist/p-map.js","module":"index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd","build":"bundt index.js"},"keywords":["promise","map","resolved","wait","collection","iterable","iterator","race","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"aggregate-error":"^4.0.0"},"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","in-range":"^3.0.0","random-int":"^3.0.0","time-span":"^5.0.0","tsd":"^0.14.0","xo":"^0.38.2","bundt":"^1.1.5"},"gitHead":"9f40622a3f367c2aa55f140e6b08b7b1fa337055","bugs":{"url":"https://github.com/sindresorhus/p-map/issues"},"homepage":"https://github.com/sindresorhus/p-map#readme","_id":"@brandonxiang/p-map@5.3.1","_nodeVersion":"14.15.0","_npmVersion":"7.21.0","dist":{"integrity":"sha512-XKSmcFwIxD0bVPSoaWsD3tfKWUIM1nF17AI+ryREgqtho8s187SSqLCUJPBBBAm2LTKShXPzJrzSqOpY/Hd1Aw==","shasum":"c61b463ba6fceb31d3f3cbfc6b628fec0a5c2b26","tarball":"https://registry.npmjs.org/@brandonxiang/p-map/-/p-map-5.3.1.tgz","fileCount":6,"unpackedSize":18717,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhofudCRA9TVsSAnZWagAAZnMQAJRtUy2qH36KzwjAC6AF\ntlxZIVueKtjPOBpXR4FHmsH585whmpk7tL0adU4Qw6/512tEzvsV/VwISF5d\n9sGIKxJJBynHkMIGH6s2s6ogcXAuxfKfaZE6E8TWapCPKpECSQ9UxR/1wb1L\ny6790gaQXnhlMg5nnp9Lxs9arjFywLstjCXw/Z/jDL7dGhS015mMSfDQZVrh\n4Z7dqR/OZolEUbazvNDuOzs4NHe26PVFOUBIovBrUL7ChL3KQT+VqCDUCdeZ\n9s7+0jgl4G/bfc2kEWmrO1dfGlZNXnL7EmV0ovqWS9ZOQ3FTusFwnn3U+LMn\n03UFWvGn1BlTfNlZ3pdMAZCgRvcCmNEAylUK0ntSRw/w7oBemyNRs9r6XgVb\nE6C1ERThJENnO4rU/bzTz6oabA8r+S4/O6j1tju/bariElFg/q/HFtOIiflz\nOhj9DJOBzK5UOwkz+5CeaIPoIaXhDC1G8Ra/C0M62G66tFcsbANsxm6gwKEK\nJ3XQQR6FLPjWBKdZLjyyli3Ecsef8C9n3EZ0Ois/LMQgXyxIFsBjfZP9PbsL\nue7N6eQPQyWzYtN01g/amX3eMNXcYUj160Q+5pGtSpHAb5f+o4roO8s93D1i\n7ijdeQXadMf+1WF6g2aD342RJa8jiSQzWg4Jgg8Ta2eO0Tm+8IWjNWCNbYAz\ne4VD\r\n=B72b\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDyvVZqpYwyrKSb/4Evi/6kFSg49+KcdGDzBkK3VZGFYQIhAIJqQ5u7Y1waEgDHguYRN1bSHyBliAPmXngCu2mynKLe"}]},"_npmUser":{"name":"brandonxiang","email":"1132500533@qq.com"},"directories":{},"maintainers":[{"name":"brandonxiang","email":"1132500533@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-map_5.3.1_1638005661639_0.32559162592301183"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-27T09:09:03.075Z","5.3.0":"2021-11-27T09:09:03.317Z","modified":"2022-04-04T20:25:52.585Z","5.3.1":"2021-11-27T09:34:21.779Z"},"maintainers":[{"name":"brandonxiang","email":"1132500533@qq.com"}],"description":"Map over promises concurrently","homepage":"https://github.com/sindresorhus/p-map#readme","keywords":["promise","map","resolved","wait","collection","iterable","iterator","race","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-map.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/p-map/issues"},"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```\n$ npm 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 [aggregated error](https://github.com/sindresorhus/aggregate-error) 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### 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## p-map for enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe 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)\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- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control\n- [More…](https://github.com/sindresorhus/promise-fun)\n","readmeFilename":"readme.md"}