{"name":"p-settle","version":"5.2.1","description":"Settle promises concurrently and get their fulfillment value or rejection reason with optional limited concurrency","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-settle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"//test":"xo && ava && tsd","test":"ava && tsd"},"keywords":["promise","settle","settled","resolved","iterator","fulfill","reject","fulfilled","rejected","reflect","inspect","error","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"p-limit":"^4.0.0","p-reflect":"^3.1.0"},"devDependencies":{"ava":"^4.3.1","delay":"^5.0.0","in-range":"^3.0.0","time-span":"^5.0.0","tsd":"^0.21.0","xo":"^0.51.0"},"gitHead":"5cf4f20aa377099ade677e012a0150205d044db7","_id":"p-settle@5.2.1","bugs":{"url":"https://github.com/sindresorhus/p-settle/issues"},"homepage":"https://github.com/sindresorhus/p-settle#readme","_nodeVersion":"25.8.0","_npmVersion":"11.12.0","dist":{"integrity":"sha512-uc27NLvvuhuuy4XfV+VCv4Ht0vJBHUUsZWVKFiZwWa3hxvHgeFVwGoEvC303jcb6SqNU2m2ipjGa08CfJK6ljQ==","shasum":"95128d60efa2ec7bd3536a4a39846ebfec895b6e","tarball":"http://registry-npm.ywwl.com/p-settle/download/p-settle-5.2.1.tgz","fileCount":5,"unpackedSize":9787,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHCku5LtFGtfpoCdubbiGC06x7xYPBjf4obpsgnHufDvAiEAsxUcZd7M59cwgC8bEZhOX5V5vCDwJQEOChQkLXrUpdI="}],"size":3386,"noattachment":false,"key":"/p-settle/-/p-settle-5.2.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/p-settle_5.2.1_1775879073542_0.6922066089037611"},"_hasShrinkwrap":false,"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":1775879073675,"_cnpm_publish_time":1775879073675,"dist-tags":{"latest":"5.2.1"}}