{"name":"p-settle","version":"5.2.0","keywords":["promise","settle","settled","resolved","iterator","fulfill","reject","fulfilled","rejected","reflect","inspect","error","async","await","promises","concurrently","concurrency","parallel","bluebird"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"p-settle@5.2.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/p-settle#readme","bugs":{"url":"https://github.com/sindresorhus/p-settle/issues"},"dist":{"shasum":"ee5a3c87b4a6154a85ac09aed2bff8d4ab3ed012","tarball":"http://registry-npm.ywwl.com/p-settle/download/p-settle-5.2.0.tgz","fileCount":5,"integrity":"sha512-ad4CPw/DzoJTt94TLG6WYvnRnP2YOKUoUQ0Wf4QX3c7yV0j+s9groOz93+OF9Ur+H2eHDwfB4H5Mml+KaEEXCw==","signatures":[{"sig":"MEQCICe0DKI4aFJG5cM0HL+cUoYeP03MPxuChj2t7fQfr6rRAiBcBUq20Q0jF2kidQiBuxyC0/a6C4lZLILYYg/JuwjWEQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9813,"size":3424,"noattachment":false,"key":"/p-settle/-/p-settle-5.2.0.tgz"},"type":"module","types":"./index.d.ts","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"exports":"./index.js","funding":"https://github.com/sponsors/sindresorhus","gitHead":"ebda1c37b82cd4c4fadeffa87ae04fb709d00aef","scripts":{"test":"ava && tsd","//test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/p-settle.git","type":"git"},"_npmVersion":"10.9.2","description":"Settle promises concurrently and get their fulfillment value or rejection reason with optional limited concurrency","directories":{},"sideEffects":false,"_nodeVersion":"20.19.1","dependencies":{"p-limit":"^4.0.0","p-reflect":"^3.1.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.51.0","ava":"^4.3.1","tsd":"^0.21.0","delay":"^5.0.0","in-range":"^3.0.0","time-span":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/p-settle_5.2.0_1757522287025_0.5648560200443997","host":"s3://npm-registry-packages-npm-production"},"readme":"# p-settle\n\n> Settle promises concurrently and get their fulfillment value or rejection reason with optional limited concurrency\n\n## Install\n\n```sh\nnpm install p-settle\n```\n\n## Usage\n\n```js\nimport fs from 'node:fs/promises';\nimport pSettle from 'p-settle';\n\nconst files = [\n\t'a.txt',\n\t'b.txt' // Doesn't exist\n].map(filename => fs.readFile(filename, 'utf8'));\n\nconsole.log(await pSettle(files));\n/*\n[\n\t{\n\t\tstatus: 'fulfilled',\n\t\tvalue: '🦄',\n\t\tisFulfilled: true,\n\t\tisRejected: false,\n\t},\n\t{\n\t\tstatus: 'rejected',\n\t\treason: [Error: ENOENT: no such file or directory, open 'b.txt'],\n\t\tisFulfilled: false,\n\t\tisRejected: true,\n\t}\n]\n*/\n```\n\nWith a `mapper` function:\n\n```js\nimport fs from 'node:fs/promises';\nimport pSettle from 'p-settle';\n\nconst files = ['a.txt', 'b.txt']; // Filenames\n\nconsole.log(await pSettle(files, {\n\tmapper: filename => fs.readFile(filename, 'utf8'),\n\tconcurrency: 2\n}));\n/*\n[\n\t{\n\t\tstatus: 'fulfilled',\n\t\tvalue: '🦄',\n\t\tisFulfilled: true,\n\t\tisRejected: false,\n\t},\n\t{\n\t\tstatus: 'rejected',\n\t\treason: [Error: ENOENT: no such file or directory, open 'b.txt'],\n\t\tisFulfilled: false,\n\t\tisRejected: true,\n\t}\n]\n*/\n```\n\n## API\n\n### pSettle(array, options?)\n\nReturns a `Promise<object[]>` that is fulfilled when all promises from the `array` argument are settled.\n\nThe objects in the array have the following properties:\n\n- `status` *(`'fulfilled'` or `'rejected'`, depending on how the promise resolved)*\n- `value` or `reason` *(Depending on whether the promise fulfilled or rejected)*\n- `isFulfilled`\n- `isRejected`\n\n#### array\n\nType: `Array<ValueType | PromiseLike<ValueType> | ((...args: any[]) => PromiseLike<ValueType>)>`\n\nThe 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.\n\nWhen using the `mapper` option, `array` can be of any type since the `mapper` function will transform each element.\n\n#### options\n\nType: `object`\n\n##### concurrency\n\nType: `number` (Integer)\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nThe number of concurrently pending promises.\n\n**Note:** This only limits concurrency for elements that are async functions, not promises. When using the `mapper` option, concurrency applies to the mapped functions.\n\n##### mapper\n\nType: `Function`\n\nFunction which is called for every item in `array`. Expected to return a promise or value.\n\nThe mapper function receives two arguments:\n- `element` - The current element being processed\n- `index` - The index of the element in the source array\n\nWhen 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.\n\n### isFulfilled(object)\n\nThis is a type guard for TypeScript users.\n\nThis is useful since `await pSettle(promiseArray)` always returns a `PromiseResult[]`. This function can be used to determine whether `PromiseResult` is `PromiseFulfilledResult` or `PromiseRejectedResult`.\n\n### isRejected(object)\n\nThis is a type guard for TypeScript users.\n\nThis is useful since `await pSettle(promiseArray)` always returns a `PromiseResult[]`. This function can be used to determine whether `PromiseResult` is `PromiseRejectedResult` or `PromiseFulfilledResult`.\n\n## Related\n\n- [p-reflect](https://github.com/sindresorhus/p-reflect) - Make a promise always fulfill with its actual fulfillment value or rejection reason\n- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently\n- [More…](https://github.com/sindresorhus/promise-fun)\n","publish_time":1757522287207,"_cnpm_publish_time":1757522287207,"dist-tags":{"latest":"5.2.1"}}