{"_id":"p-reflect","_rev":"8-e74cbce9c544ab262801a1026b17eb1d","name":"p-reflect","description":"Make a promise always fulfill with its actual fulfillment value or rejection reason","dist-tags":{"latest":"3.1.0"},"versions":{"1.0.0":{"name":"p-reflect","version":"1.0.0","description":"Make a promise always fulfill with its actual fulfillment value or rejection reason","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-reflect.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","reflect","inspect","debug","fulfill","reject","fulfilled","rejected","error","async","await","promises","bluebird"],"devDependencies":{"ava":"*","xo":"*"},"xo":{"esnext":true},"gitHead":"3a34b40964d98e33afdd6656bcf5addcf4219a96","bugs":{"url":"https://github.com/sindresorhus/p-reflect/issues"},"homepage":"https://github.com/sindresorhus/p-reflect#readme","_id":"p-reflect@1.0.0","_shasum":"f4fa1ee1bb546d8eb3ec0321148dfe0a79137bb8","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"f4fa1ee1bb546d8eb3ec0321148dfe0a79137bb8","tarball":"https://registry.npmjs.org/p-reflect/-/p-reflect-1.0.0.tgz","integrity":"sha512-rlngKS+EX3nvI7xIzA0xKNVEAguWdIqAZVbn02z1m73ehXBdX66aTdD0bCvIu0cDwbU3TK9w3RYrppKpO3EnKQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDQjbLESeA88TKYa6BloyY0zlhQY8e0wY5Ck6jmxDt6DgIhALgSVXxYQEKcT3Nx6fzYXzMwF/ir/s5k81B/BnLdozJ3"}]},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-reflect-1.0.0.tgz_1480137925930_0.7492805134970695"},"directories":{}},"2.0.0":{"name":"p-reflect","version":"2.0.0","description":"Make a promise always fulfill with its actual fulfillment value or rejection reason","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-reflect.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","reflect","inspect","debug","fulfill","reject","fulfilled","rejected","error","async","await","promises","bluebird"],"devDependencies":{"ava":"^1.3.1","tsd-check":"^0.5.0","xo":"^0.24.0"},"gitHead":"e78fbc51dd0cdc571ccaa603d65f60a2b179658f","bugs":{"url":"https://github.com/sindresorhus/p-reflect/issues"},"homepage":"https://github.com/sindresorhus/p-reflect#readme","_id":"p-reflect@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-mCy5T0OSpOM6vjfBQVV4/F52aSnDiloslPGjRsp0WpZd9cbS+t+PGFezDdCovKj/Y9Lg3mG58xil+W9KTqbuUQ==","shasum":"71768ac35af2cb055aeb1edf14bd4d6c4c450674","tarball":"https://registry.npmjs.org/p-reflect/-/p-reflect-2.0.0.tgz","fileCount":5,"unpackedSize":5406,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcj8yiCRA9TVsSAnZWagAAoWcQAIpymiNStvUUiD42PTgk\nMvTQ0xM7TA7pUTU/ZOxImavOt2BkNVxAP2vH974/ZkBgpOhVX5w4J+4022mc\nWeZXM8VdF1kgYnzAu5MRG8RgpXoXVffJll2Y1muN0njtQGC0N9jV19/QOP7g\n2Ab8bJV40PsaPITgDTyk5sHQyYtp2mK1H+56akasLKM4QJNJk+7Fb2B1+Ueg\nI4e0ZSZWl1xf/40wSC2ThiuyyE3D5b3/xXogaPuOq9n8qR4ibfQp8UNEXz9P\nTO60c1nRZzvGqwvwejn1qW3YUIL5RWJ26qoAureGZdLx5tCYHi5SxqLTjCzy\nVn3yR4FVHQLnGCSFNSBw9i2EARU44Na9DuE3SrCoqHHoLxhR/K+dmFjUtzqf\nZ9l41hle65tZ0CRqbb90UMRTg73UHbKConHGqjeLl6FRn+eUEf/8BMvf7SF+\njbYCDSW2y68GMqjmOz7tftdPw5nIl0K91E7U7MMyDsX1eFkL7jexub+xOAiG\nq8mGoGzMps3I6aV97b9B5KkZcjvqir54NDjdQJzAnVco/hpS/HrmTMeuvHDh\ngo9HXypw3GdnoY6OuLhsXLqsLZQf+NmCr8h5RWbl+BgQrYYlc9eOsbUFJx3R\nwMylQXX/cRaHNbzXXKJl1u3qeCBc53OEIY046xCNt2R6j7Jc0P7oC8iKh1wH\n9REq\r\n=8BGB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC5lhbB20995v/AWanIhsd/9OU0FTzOP4jxLT4N/KLQVAiEA2YUUX5McwZMYJXScoatZZwLnVluxoApOIVAod2SbMGM="}]},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-reflect_2.0.0_1552927905217_0.18195580185057691"},"_hasShrinkwrap":false},"2.1.0":{"name":"p-reflect","version":"2.1.0","description":"Make a promise always fulfill with its actual fulfillment value or rejection reason","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-reflect.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","reflect","inspect","debug","fulfill","reject","fulfilled","rejected","error","async","await","promises","bluebird"],"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"d0141ac1dd4319cd6eda7f88b6fa73384dded212","bugs":{"url":"https://github.com/sindresorhus/p-reflect/issues"},"homepage":"https://github.com/sindresorhus/p-reflect#readme","_id":"p-reflect@2.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-paHV8NUz8zDHu5lhr/ngGWQiW067DK/+IbJ+RfZ4k+s8y4EKyYCz8pGYWjxCg35eHztpJAt+NUgvN4L+GCbPlg==","shasum":"5d67c7b3c577c4e780b9451fc9129675bd99fe67","tarball":"https://registry.npmjs.org/p-reflect/-/p-reflect-2.1.0.tgz","fileCount":5,"unpackedSize":5809,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpEN3CRA9TVsSAnZWagAAWNMP/R1t2vf5STbvK1SqDZQs\n2Rv1Srw7dsMoiiy3tTR59EpLnlSxKXSvE6rIRu6E7544LfqLggkCTemPs+Q6\nPVKscgmqFdjZJREMwm6d/SMvgyEzh76mFHzFeD0An9ukL4JcCQe2XQjrH7xc\naAmKcl3I0YNcYQHJNxKdCugFLDc9ri5PvaqscKSs4Qnd10U8YmSwQDx/NIOE\nk2pkwqjjptPlBLmgljT1sJ+M+mykV9aej66n7ir1hiqwpIJw2gLcYGXFIav3\nMaJ7wbiID4Wc/qB3UHezyF0MJs0wMEaKmyBQ2zlB1dNcYMlzw+boSFXca/fG\n/bj6tMFV0cnRFtI9pzyUk6sh3wgVfjNbloo53k7RA1t9RWOMP33fFyv7kitO\nDOBb4A+Ac9OnXh24kbkFe9SYvRI9fEVl6/hMhxo5vkDgaKEFL73QkP+bLcuR\nC6cPtqom6OumvljVE3FoIwxRAeEd4YriR6B70eMUZlzXlIX7RamiHa5Tr7i9\nNxaWYljaao7fyzBDGjMYnLNvHZ6B9penmUnNZorphWArlR+NR04W0in02EB/\nvCD9e/9AzJG8Rq50jQfr4NxfYD04fG8m1fqnAaJYoZlZfkVQQDHt3cUees/Z\n+24kEFHPl/0NkZ0+Jql+GWWwl+GuEI4wr0j/0qrByPtRUoqBRns27GSfpSTn\njp/f\r\n=I3gh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBO8gJWeexC5GdAzeZlxwvJUkbDJHGka319QKS1O2O+3AiB03g81iTCFVZg6caDiMOpERomiC2fz2TgfpTds9QeENw=="}]},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-reflect_2.1.0_1554269046665_0.8621619656430015"},"_hasShrinkwrap":false},"3.0.0":{"name":"p-reflect","version":"3.0.0","description":"Make a promise always fulfill with its actual fulfillment value or rejection reason","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-reflect.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","reflect","inspect","debug","fulfill","reject","fulfilled","rejected","error","async","await","promises","bluebird"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"180058ffbe18d2df8475ccb454db0ddbcad31771","bugs":{"url":"https://github.com/sindresorhus/p-reflect/issues"},"homepage":"https://github.com/sindresorhus/p-reflect#readme","_id":"p-reflect@3.0.0","_nodeVersion":"15.12.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-rOgYyrvUxnJdSYKGSK7UnO7RxFSnT/IJYFPiosuQ2/AtRWIryIrv8lecWqJXWbKnMcUjJvxiHDMp80m0Yj4eLA==","shasum":"2473a6f9ee0376a27723b18efd24911db8e92573","tarball":"https://registry.npmjs.org/p-reflect/-/p-reflect-3.0.0.tgz","fileCount":5,"unpackedSize":5151,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgb0qNCRA9TVsSAnZWagAAfaMP/00yfG6frpEP4wPNB0Sm\n8arqjZ0KBE75L+Gjo4x4SMc0urBUTZjw/JIwRtI+z6aIK+agcRfnV7jeNxbL\nxPGat1R+k5apkXK2I0yV3rvmpWUWj/vF3ozKFijgtpEfZUlKppFEJim81A98\nZGuECBIwvJ+7dPx1lmOO0Ja14X+35XNW+Yj/G1y6O5tj8WSQTgebALEB4mqt\nW9a5PfVJEg9x2n9YDjOCcaoRSoZNE5OAqA9jDCeR/uvG/gLtinOvpMiBXeBJ\nUtKOWzt/p24FsRtqdV8iU0716NPY2VJJENZZOOfFsh6+lRQrquhmTx8RsPZ/\nG6bN8o2YXsw4+LO5T9/2vXaJ81eNtxVXYwY9TWXbkgCfd2mYZvD7LjAnyaQb\nd6bOG2dC9lSlzsDDfaCjB+yoN0TnLuvfBtj4nfwHSNG61duuuy3m5sKosNBp\nKNduZAQN4JjjhItcVLAbJOZ9J0O5Qa2/dWNt0PpscBYOwChj/Hv/yjNag9Ye\n/7pG6so4iS9/dO2W7QTAvB11r1+bKjwktMuC6s2b6Rr3uWWeMi2KVNt7eYQY\nc9uiEZvbZ+R2qbq6baZxR7Is+N/QB2CsHpbTqIFqvEnKQwR9H8dikfvGoAoM\nQcTkkkEnQpRVEy5jIB7uDkUmG91Jslm2UOY/NDZj8NNFo1hNHk1b7W+Wan9U\nX/mC\r\n=fZoX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCFUYYYZ0YFpShd0uyrjtxtFYfw7DKr5ToJ49xNcD6S1gIgaAGpxZ3X70lW3f3YmOhbMBOGdOYDVUC3J2beIgDdvx0="}]},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-reflect_3.0.0_1617906316916_0.42553299052979554"},"_hasShrinkwrap":false},"3.1.0":{"name":"p-reflect","version":"3.1.0","description":"Make a promise always fulfill with its actual fulfillment value or rejection reason","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-reflect.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","reflect","inspect","debug","fulfill","reject","fulfilled","rejected","error","async","await","promises","bluebird"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"types":"./index.d.ts","gitHead":"504690bc03ebf9996f85433e8d08957ced880ab9","bugs":{"url":"https://github.com/sindresorhus/p-reflect/issues"},"homepage":"https://github.com/sindresorhus/p-reflect#readme","_id":"p-reflect@3.1.0","_nodeVersion":"14.19.3","_npmVersion":"8.3.2","dist":{"integrity":"sha512-3sG3UlpisPSaX+o7u2q01hIQmrpkvdl5GSO1ZwL7pfc5kHB2bPF0eFNCfYTrW1/LTUdgmPwBAvmT0Zr8eSmaAQ==","shasum":"bba22747439b5fc50a7f626e8e909dc9b888218d","tarball":"https://registry.npmjs.org/p-reflect/-/p-reflect-3.1.0.tgz","fileCount":5,"unpackedSize":7113,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCwQmBb+eDNePhjjwgizh1P++CVHo3iNDYPP1sVK84+9gIgCfOArhgOK1gK7qJ2R9GgVMNx+g+Ykr8m0Ui22HONa3Q="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi3soVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoBvQ//UajOUrtTcw3M+x0HvWpOcBkDMz3qyFQC1cPFKXZIaoxtmI9H\r\nxCgigKwKMSd1O1E6ufNW0Ig14COrvrPH6JUBR/3C8jOVCGXC+usP1uQOBy07\r\nw2j9ud1URVV6AB+/mjdYTT8MB9CXOq/gDCBwAJJLlH5KrosLXJtR1kVkSMOw\r\nnms7ByYHH2xLBKpfNcDqMQ4FaGP+81V3TgkR1BHx950QXsK17l1/LENOyM41\r\np6hsXZOcvrD91EIcJQ85zJgjdPQFdLeI3aDUWsHAf+fgoI2oAsFYqHYW6yvD\r\ni6gJgdukdBOSB5v74dypi8FTP7SkbO+pcBKWRaDXWDFDGyKM9QbMyuFacX+8\r\nyQC5Hf8X0mVxvvdpi6wL806bVJrTGfXIUQQmy5530AgfyeM84e9zUPoybqTB\r\n6LTzIm/5KKR77retdg48TR+7NF/5zcVqi6GBQxmPWCxbQqy24dvG9oPwYnXn\r\n2IS13BIljkQXGjYJPaEQWWBJIQ//GzyDyFZ+RpN8JcXx7QuxSwl6MASFPXPD\r\nVG/8iF+4AvhL9OQILvXxnOqOBb7iMd7czL0c+A2GlAZ53K4aUziTnRXYDbpQ\r\npPU6U3ZIa51KzeMLfCACUlPGaiwYcfgBpMejPcMICO5IKCv31mypZWeUzMe3\r\no5TwUaOqLQ3eOYcZ6+6TUKQuX9yDpFF3fkY=\r\n=diRJ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-reflect_3.1.0_1658767893165_0.5925878106167497"},"_hasShrinkwrap":false}},"readme":"# p-reflect\n\n> Make a promise always fulfill with its actual fulfillment value or rejection reason\n\nUseful when you want a promise to fulfill no matter what and would rather handle the actual state afterwards.\n\n## Install\n\n```\n$ npm install p-reflect\n```\n\n## Usage\n\nHere, `Promise.all` would normally fail early because one of the promises rejects, but by using `p-reflect`, we can ignore the rejection and handle it later on.\n\n```js\nimport pReflect from 'p-reflect';\n\nconst promises = [\n\tgetPromise(),\n\tgetPromiseThatRejects(),\n\tgetPromise()\n];\n\nconst results = await Promise.all(promises.map(pReflect));\n\nconsole.log(results);\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: 👹]\n\t\tisFulfilled: false,\n\t\tisRejected: true\n\t},\n\t{\n\t\tstatus: 'fulfilled',\n\t\tvalue: '🐴'\n\t\tisFulfilled: true,\n\t\tisRejected: false\n\t}\n]\n*/\n\nconst resolvedString = results\n\t.filter(result => result.isFulfilled)\n\t.map(result => result.value)\n\t.join('');\n\nconsole.log(resolvedString);\n//=> '🦄🐴'\n```\n\nThe above is just an example. Use [`p-settle`](https://github.com/sindresorhus/p-settle) if you need exactly that.\n\n## API\n\n### pReflect(promise)\n\nReturns a `Promise<Object>`.\n\nThe object has 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#### promise\n\nType: `Promise`\n\nA promise to reflect upon.\n\n### isFulfilled(object)\n\nThis is a type guard for TypeScript users.\n\nReturns `true` if the object has the property `value`, `false` otherwise.\n\nThis is useful since `await pReflect(promise)` always returns a `PromiseResult`. This function can be used to determine whether `PromiseResult` is `PromiseFulfilledResult` or `PromiseRejectedResult`.\n\nThis is a workaround for [microsoft/TypeScript#32399](https://github.com/microsoft/TypeScript/issues/32399)\n- reference documentation [Using type predicates](https://www.typescriptlang.org/docs/handbook/2/narrowing.html)\n\n### isRejected(object)\n\nThis is a type guard for TypeScript users.\n\nReturns `true` if the object has the property `reason`, `false` otherwise.\n\nThis is useful since `await pReflect(promise)` always returns a `PromiseResult`. This function can be used to determine whether `PromiseResult` is `PromiseRejectedResult` or `PromiseFulfilledResult`.\n\n## Related\n\n- [p-settle](https://github.com/sindresorhus/p-settle) - Settle promises concurrently and get their fulfillment value or rejection reason\n- [More…](https://github.com/sindresorhus/promise-fun)\n","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"time":{"modified":"2022-07-25T16:51:33.475Z","created":"2016-11-26T05:25:26.154Z","1.0.0":"2016-11-26T05:25:26.154Z","2.0.0":"2019-03-18T16:51:45.331Z","2.1.0":"2019-04-03T05:24:06.813Z","3.0.0":"2021-04-08T18:25:17.026Z","3.1.0":"2022-07-25T16:51:33.393Z"},"homepage":"https://github.com/sindresorhus/p-reflect#readme","keywords":["promise","reflect","inspect","debug","fulfill","reject","fulfilled","rejected","error","async","await","promises","bluebird"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-reflect.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/p-reflect/issues"},"license":"MIT","readmeFilename":"readme.md"}