{"name":"p-settle","version":"4.1.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"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && 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":"^2.2.2","p-reflect":"^2.1.0"},"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","in-range":"^2.0.0","time-span":"^3.1.0","tsd":"^0.11.0","xo":"^0.30.0"},"gitHead":"3f03ec5aa76659cfef5eea1e5bfc6e5fdfab37f4","bugs":{"url":"https://github.com/sindresorhus/p-settle/issues"},"homepage":"https://github.com/sindresorhus/p-settle#readme","_id":"p-settle@4.1.0","_nodeVersion":"10.20.1","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-4SdSDDOsf9QEigsscXuddUBv2V8H+a823JGndXpoDeosL1Ah1da8YSGMF5EZcfih6toY1+kFdmKQ87+bGVmwqQ==","shasum":"ae459f812de9599e68ba72d815d1c22376e61e3d","tarball":"http://registry-npm.ywwl.com/p-settle/download/p-settle-4.1.0.tgz","fileCount":5,"unpackedSize":6409,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexhs1CRA9TVsSAnZWagAABZoP/RI+Y7Zi9VTa51XHN/qA\nQIipfo8efJwCyA8HIrdip4dQ47FYb3CxQQixrEHu0yvjszcfWkBNEAr0iWJe\ne9mtbDCcfa0lA5ClKqqJ6HFJnHeDFGogds0F98koITJgenDdH+xVvBAM13ws\nCna057NXUzPYeP6lZDlo2jPgx7QB4FJadWQ/rifrDBuiEWiYlZseJqpKUfa8\n5Us9h0e+S4VyM79CYOYeLlsJ59pb2I/d6/6M6yYTN+rOvYYi7mKMznIN8aCz\ngFUyh0pAi23naaSDz79iAEY2Yra/02zMYWVc41famdrU1lkGfwCNVqeNYGW/\nTrKyZUYWxP86V4xInX3BCRs9vJB8i4FFEB+9pFmmWvKd5kYCBzYEGJKevAGO\nij413k/dXX+NAa0zjSnf3HCkeBgwNAS04BeuZBS0ylsl2uSpHu22YB0FBIcJ\njHjsSosPhuaJvs/5ZTyrmb/KeI74fB5BGHsRMXFVU6+Z2jrfFD5UOC02Z06S\nC/xBJoZHCm591mUdEHgdljs5di1xn9j4ZdBVwf3hcehP+tXouoqhJSuz/x0k\nNI1iach/Rv15SjNDvGlEQLzR93jdtznGt8LXtRuAVO9SeTuixDXx0MKwg7DE\n+mihx63I+aRWekdweDwaUqy2TAvrFrncVNhdMqoIIp94UIjV0c2255qjzUMU\nqRBp\r\n=Mumg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCH24jAu2wW82kwL2FUDy0MP2esQBVWrFNeZiaxit7rrYCIBAQEAQJscQOQuRwin37AdxFbjoURaQCkCqMc11udJTj"}],"size":2787,"noattachment":false,"key":"/p-settle/-/p-settle-4.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-settle_4.1.0_1590041396792_0.1675498120034029"},"_hasShrinkwrap":false,"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":1590041396893,"_cnpm_publish_time":1590041396893,"dist-tags":{"latest":"5.2.1"}}