{"name":"p-settle","version":"1.0.0","description":"Settle promises concurrently and get their fulfillment value or rejection reason","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-settle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","settle","settled","resolved","iterator","fulfilled","rejected","reflect","error","async","await","promises","concurrently","concurrency","parallel","bluebird"],"devDependencies":{"ava":"*","delay":"^1.3.1","xo":"*"},"xo":{"esnext":true},"gitHead":"04031f4b3d103c64203f2620d6afa1b132dde610","bugs":{"url":"https://github.com/sindresorhus/p-settle/issues"},"homepage":"https://github.com/sindresorhus/p-settle#readme","_id":"p-settle@1.0.0","_shasum":"1f83b402c248ab285f37b6dab7bccf28e9e6aed8","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"1f83b402c248ab285f37b6dab7bccf28e9e6aed8","tarball":"http://registry-npm.ywwl.com/p-settle/download/p-settle-1.0.0.tgz","integrity":"sha512-MKgU5eBFYZ+96Nl8hN2RwqLKIffPAlPMg/iEUb1yzE49tRG2/Poz9lSplQrvj4bD5pOewLuCNogrThvSIn9GHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICOa9njT3ElmmqoVv+iywDIRfokAw2azxXETTFbjAstaAiEA+XicuxtHQDDiy0cyX9Fu3tm+oRi+y+ERPnN2ROSmn3I="}],"size":1990,"noattachment":false,"key":"/p-settle/-/p-settle-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-settle-1.0.0.tgz_1477031317916_0.20328983617946506"},"directories":{},"readme":"# p-settle\n\n> Settle promises concurrently and get their fulfillment value or rejection reason\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\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\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.\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":1477031318150,"_cnpm_publish_time":1477031318150,"dist-tags":{"latest":"5.2.1"}}