{"_id":"await-handler","_rev":"6-8d83b708d944fa174006498785e36f6f","name":"await-handler","description":"Basic wrapper for await that allows handling of errors without try/catch blocks","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"await-handler","version":"1.0.0","description":"Basic wrapper for await that allows handling of errors without try/catch blocks","main":"index.js","scripts":{"test":"mocha test.js"},"repository":{"type":"git","url":"git+https://github.com/KyleRoss/await-handler.git"},"keywords":["await","error","handler","try","catch","block","async","asyncawait","trycatch"],"author":{"name":"Kyle Ross","email":"thejavascriptguy@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/KyleRoss/await-handler/issues"},"homepage":"https://github.com/KyleRoss/await-handler#readme","devDependencies":{"mocha":"^4.0.1"},"gitHead":"f2d53d380b8577447ea95fe35f0bf595f92f7c3b","_id":"await-handler@1.0.0","_shasum":"8d556b75787f591c1eac1ee4defdb5520b3436e2","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"kyleross","email":"kylerross1324@gmail.com"},"dist":{"shasum":"8d556b75787f591c1eac1ee4defdb5520b3436e2","tarball":"https://registry.npmjs.org/await-handler/-/await-handler-1.0.0.tgz","integrity":"sha512-H3G61LqqOge+SK/JdmIUKklFPGK4yzaEJqDNKGR+j6coAIE3TxjwiRUsPBBnXH/Ovf1TXft6OoejgMf8In9r+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDdYoGqmhQVw78Uz2YRbQLyGIiJpCq2hT7xkSsB71DZCQIgerZ84hoMF1DkWyBkLJHpjCPgD+8FAf4d69g16GPXFTk="}]},"maintainers":[{"name":"kyleross","email":"kylerross1324@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-handler-1.0.0.tgz_1509644826403_0.6705834663007408"},"directories":{}},"1.1.0":{"name":"await-handler","version":"1.1.0","description":"Basic wrapper for await that allows handling of errors without try/catch blocks","main":"index.js","scripts":{"test":"mocha test.js"},"repository":{"type":"git","url":"git+https://github.com/KyleRoss/await-handler.git"},"keywords":["await","error","handler","try","catch","block","async","asyncawait","trycatch"],"author":{"name":"Kyle Ross","email":"thejavascriptguy@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/KyleRoss/await-handler/issues"},"homepage":"https://github.com/KyleRoss/await-handler#readme","devDependencies":{"mocha":"^4.0.1"},"gitHead":"e5c4bf4775e0a922a90cdca74b9a21d85ac93669","_id":"await-handler@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.7.0","_npmUser":{"name":"kyleross","email":"thejavascriptguy@gmail.com"},"dist":{"integrity":"sha512-AYY1IVVWacfpAOzdWs2vrHzavhnZa2C+lRfiAiNWf73/XmUDz5AMKrQl50GXcIhA0R+Q5U67TRlXQCqvccr5BA==","shasum":"b8bd5e0c23c910ed6b1006c832cb635331e8ce5c","tarball":"https://registry.npmjs.org/await-handler/-/await-handler-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFXa002/pzy/eEkz+XPREwAVOsyoPuux1bCj+/gG1FIqAiAXvNme0Ozv6umOIsN15x+sAjaQFhR0TDN9yZRdGEUW7A=="}]},"maintainers":[{"name":"kyleross","email":"kylerross1324@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-handler-1.1.0.tgz_1514916697020_0.888612374663353"},"directories":{}},"1.1.1":{"name":"await-handler","version":"1.1.1","description":"Basic wrapper for await that allows handling of errors without try/catch blocks","main":"index.js","scripts":{"test":"mocha test.js"},"repository":{"type":"git","url":"git+https://github.com/KyleRoss/await-handler.git"},"keywords":["await","error","handler","try","catch","block","async","asyncawait","trycatch"],"author":{"name":"Kyle Ross","email":"thejavascriptguy@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/KyleRoss/await-handler/issues"},"homepage":"https://github.com/KyleRoss/await-handler#readme","devDependencies":{"mocha":"^5.2.0"},"gitHead":"92f81620efc282cb485cfaa8b32fea399f80b757","_id":"await-handler@1.1.1","_npmVersion":"6.0.1","_nodeVersion":"8.11.2","_npmUser":{"name":"kyleross","email":"thejavascriptguy@gmail.com"},"dist":{"integrity":"sha512-qaDXHWNVsSn1el4TONlo8knAQkFYOzfyK0DH+MTibhImCYtEw3ZPSL+fJuz5PQc6o1/LmJA00FiUpfhQih0+Rw==","shasum":"16e97ed3d730bcbddff40c1c44a7c6362c122982","tarball":"https://registry.npmjs.org/await-handler/-/await-handler-1.1.1.tgz","fileCount":7,"unpackedSize":7786,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbECxwCRA9TVsSAnZWagAA1CkQAKOA1dvwHrcqnGrqPpq9\n7/bHDfpPgbclfFBYekMwKGJTAsvnm6ZIK0Rd2GPmrjpi2Ywd8hwOtiMm2Ddk\nzZNnvuxJK2TcX04Xx9pzpNyxq3QPbkB3IRnY2oY3Zbda9jLq6koHpl7BAFXV\nMR/mPhiwo/YPbmzJ2hIuiy+Wt7vWuj7Wk/BCAPfHcZgcJZTEpXpTRRnkztvl\nisPeyH6YM0VBbHzDQdrpKPbzircwoDqyRqgR2E4Yg3M0em+j/4+IguoGS+xI\n02H0EazDN7AprAy5XuYhhtF+8BRc0nJD/mpH9ARPeNSpTVhaUIT7PcS0mX3p\nXA83Th+32SGSIgth8yMau4TH3lOBwjC7ilTzHdx6TaAB41rqeJpeSF6VHtcm\nci7umkrqTFcnFLqhRiy/8n7fTmRDBj23u2haeG2UgqGg8h1bSdat68ATgh98\n/Z1RdZReTxJBWREJ9OgMBiNG/Aydk3/0eosjAZiAE03mknKMq2165fNduXYF\n7PZi0jqMn1akG4QW0Or0IhQ5Cdb11cVso7OYkubPvJQjxjw4cyzDAKZ5QLLO\n0EyEP+xY/sRTF5VqCxpbl+HvHC/chkkiZYMKDIBFN9jdT7w8EVEdLaZT4cCu\nm9br86rilMQQ/RGex9d9HoXkx9BF9mnVzm+zUpx6puK4Co/Yo8Xp0WoeFOPd\nq9CR\r\n=YJDH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDx5DmIkIdAGJgp9t+5CMub0YgaGArn6iWll+F3/UiuBAiA4CrxCmzdwmnFISnIHEhykdPsV1NTNTbD1VizhwoqhOQ=="}]},"maintainers":[{"name":"kyleross","email":"kylerross1324@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-handler_1.1.1_1527786607901_0.678277288701489"},"_hasShrinkwrap":false},"1.1.2":{"name":"await-handler","version":"1.1.2","description":"Basic wrapper for await that allows handling of errors without try/catch blocks","main":"index.js","scripts":{"test":"mocha test.js"},"repository":{"type":"git","url":"git+https://github.com/KyleRoss/await-handler.git"},"keywords":["await","error","handler","try","catch","block","async","asyncawait","trycatch","go","golang","signature","await-to-js","awaittojs"],"author":{"name":"Kyle Ross","email":"thejavascriptguy@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/KyleRoss/await-handler/issues"},"homepage":"https://github.com/KyleRoss/await-handler","devDependencies":{"mocha":"^5.2.0"},"gitHead":"4b704753f91f23eced1c996e16c2732f36a6ebe1","_id":"await-handler@1.1.2","_npmVersion":"6.1.0","_nodeVersion":"8.11.2","_npmUser":{"name":"kyleross","email":"thejavascriptguy@gmail.com"},"dist":{"integrity":"sha512-dihteGhwbJpT89kVbacWiyKeAZr+En0YGK6pAKQJLR0En9ZxSH2H4TTvfG4bBjzFq9gDAma4y9BrpDns6j5UiQ==","shasum":"329c19e9382599898bc12c80c47efdcdaa1b4992","tarball":"https://registry.npmjs.org/await-handler/-/await-handler-1.1.2.tgz","fileCount":7,"unpackedSize":8486,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbP4QmCRA9TVsSAnZWagAAoy8P/AjLMuM8tIOxZE/JVtIH\nQWgJhOCwdppt9VvqXoxT6zpZvBluvrz1DqLL5dt/K7oXjpXfe/R8CVEA0qcZ\nN1mQcHIQKZ5cVR1yt7LN4zQfKWoMX7QfFUqw/vWPwtNGjhtFqWZ1/4JVxjD5\nxiSdcFby28MY5BpVLmdrsP3yF8Iui57/+x73dsHMlEtKS0FgvTwjIDrRUYLG\nEBn5Fc17QRYqhzeRc5e6iD2oA4MRUoFspLy2ifzIjC3hTGld5lCDoL7gOxDN\nb2hCYciC43eBxxV9Z+9vYUrXhtxBDECx5kzPeE5nJOorig5/CqctDGX2MpHI\nrMtBlE98xrJghO7jye8ZEnicy9la3jejbBHGZW3C88slFg9QgN4FB0qayyjp\nHvuzk6fnuDhA/gCMb8jO5HzkmgfYV7POGhtoSkdSde5iXVKbpXN6J3fafpom\nWnhJyqRIaZ5qGBUZ2SaiFriZSkJW0lwWnKcBKsakWTHUa/Hp40LrevcOOih/\nmxJszCgbAHvlBCFMFO6mXP9jllEK9OI+eFwUPJxGRbov559xD5NAYEWiAcsu\nM/iwjpEZKSFpU/SNVidtqysZp5f/q2nJb+dUkic3z2P8SDlVpgo5Mv7E2b7X\nJQtr95k4DyoFJy//XQi53amVzOH8N7WgjX6T0CDiu3VptRmkXln3kkJVEgwv\nI2wM\r\n=gj1d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDAQpsIdse1soi/Y+2r5KeG9mTCUDxUcgazPKE9EdoBOgIhAPjZzkUtWErgYHpK+fObozXTHWOb1ba78kaH2+Nn9bEB"}]},"maintainers":[{"name":"kyleross","email":"kylerross1324@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-handler_1.1.2_1530889254547_0.4401774999038932"},"_hasShrinkwrap":false}},"readme":"# await-handler\n[![npm](https://img.shields.io/npm/v/await-handler.svg?style=for-the-badge)](https://www.npmjs.com/package/await-handler) [![npm](https://img.shields.io/npm/dt/await-handler.svg?style=for-the-badge)](https://www.npmjs.com/package/await-handler) [![David](https://img.shields.io/david/KyleRoss/await-handler.svg?style=for-the-badge)](https://david-dm.org/KyleRoss/await-handler) [![Travis](https://img.shields.io/travis/KyleRoss/await-handler/master.svg?style=for-the-badge)](https://travis-ci.org/KyleRoss/await-handler) [![license](https://img.shields.io/github/license/KyleRoss/await-handler.svg?style=for-the-badge)](https://github.com/KyleRoss/await-handler/blob/master/LICENSE) [![Beerpay](https://img.shields.io/beerpay/KyleRoss/await-handler.svg?style=for-the-badge)](https://beerpay.io/KyleRoss/await-handler)\n\nSimple signature to ease the paid of catching errors using async/await. This module will allow a simple method of catching errors from an `await` handler without the need to wrap everything in try/catch blocks. This module is a Node.js only version based on [await-to-js](https://github.com/scopsy/await-to-js) minus the typescript aspect. Credit for this module goes to [Dima Grossman](http://blog.grossman.io/how-to-write-async-await-without-try-catch-blocks-in-javascript/), as it was based off the code provided.\n\nYou continue to use async/await normally, except to wrap the function you are \"awaiting\", in this module to allow destructuring the returned array into variables. This is similar to the golang error handling syntax.\n\n**NOTE:** This module works in Node 6+, but in order to use async/await, you need to use Node 8+ or compile with Babel.\n\n## Install\nInstall via NPM:\n```\nnpm i await-handler --save\n```\n\n## Usage\n```js\nconst on = require('await-handler');\n\nasync function asyncFunctionExample() {\n    let [err, result] = await on(myAsyncTask());\n    if(err) {\n        throw err;\n    }\n    \n    // ... handle the result\n    console.log(result);\n}\n```\n\n## API\n\n### on(promise[, errorProps])\n**Type:** Function\n\nAdds handler to `promise` in order to return an array which can be destructured. Optionally add additional properties to the returned error by providing an Object to `errorProps`.\n\n| Argument   | Required? | Type    | Description                                                |\n|------------|-----------|---------|------------------------------------------------------------|\n| promise    | Yes       | Promise | Promise to wrap and return results for.                    |\n| errorProps | No        | Object  | Optional object to append to the `Error` if one is thrown. |\n\n**Examples:**\n```js\nasync function basicExample() {\n    let [err, result] = await on(myAsyncTask());\n    if(err) throw err;\n    \n    // ... handle the result\n    console.log(result);\n}\n\nasync function errorPropsExample() {\n    let [err, result] = await on(myAsyncTask(), { customMessage: 'Something failed!' });\n    if(err) {\n        console.error(err.customMessage);\n        return process.exit(1);\n    }\n    \n    // ... handle the result\n    console.log(result);\n}\n```\n\n###### Returns _{Promise&lt;Array&gt;}_\n> Returns Promise that resolves with array signature `[error, results]`. If an error is thrown, `error` will be the the rejection from the promise and `results` will be `undefined`. If an error is not thrown, `error` will be `null` and `results` will be the resolved value from the promise.\n\n---\n\n## Tests\nTo run the tests:\n\n```\nnpm install\nnpm run test\n```\n\n## License\nMIT License. See [License](https://github.com/KyleRoss/await-handler/blob/master/LICENSE) in the repository.\n","maintainers":[{"name":"kyleross","email":"kylerross1324@gmail.com"}],"time":{"modified":"2022-06-13T03:52:40.697Z","created":"2017-11-02T17:47:07.348Z","1.0.0":"2017-11-02T17:47:07.348Z","1.1.0":"2018-01-02T18:11:37.961Z","1.1.1":"2018-05-31T17:10:07.983Z","1.1.2":"2018-07-06T15:00:54.639Z"},"homepage":"https://github.com/KyleRoss/await-handler","keywords":["await","error","handler","try","catch","block","async","asyncawait","trycatch","go","golang","signature","await-to-js","awaittojs"],"repository":{"type":"git","url":"git+https://github.com/KyleRoss/await-handler.git"},"author":{"name":"Kyle Ross","email":"thejavascriptguy@gmail.com"},"bugs":{"url":"https://github.com/KyleRoss/await-handler/issues"},"license":"MIT","readmeFilename":"README.md"}