{"_id":"@antoniovdlc/await-on","_rev":"4-79016e39fa0dd756c697c731bcaf6b1e","name":"@antoniovdlc/await-on","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.3":{"name":"@antoniovdlc/await-on","version":"0.0.3","description":"","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"jest","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["async","await","await-on","error","handling","promise"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/await-on.git"},"bugs":{"url":"https://github.com/AntonioVdlC/await-on/issues"},"homepage":"https://github.com/AntonioVdlC/await-on#readme","license":"MIT","devDependencies":{"@babel/core":"^7.14.6","@babel/preset-env":"^7.14.5","@babel/preset-typescript":"^7.14.5","@rollup/plugin-typescript":"^8.2.1","@types/jest":"^26.0.23","babel-jest":"^27.0.2","eslint":"^7.29.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jest":"^24.3.6","husky":"^6.0.0","jest":"^27.0.4","lint-staged":"^11.0.0","prettier":"^2.3.1","rimraf":"^3.0.2","rollup":"^2.52.1","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.3.4"},"gitHead":"5e57849f11a6ef099bdb1d98e0591c6cd96f8f83","_id":"@antoniovdlc/await-on@0.0.3","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-IhYAVWARXCZvk1XvKHOlcGc5VCh/AboT9iF6UyHjuzmhE8mVL6vC/+7LJMYCFEBDYe6NjkeV9n19nBCx+jNuwA==","shasum":"fb1ef3bcb115d590b1c90fd5c2061cb0e2583550","tarball":"https://registry.npmjs.org/@antoniovdlc/await-on/-/await-on-0.0.3.tgz","fileCount":6,"unpackedSize":6969,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgz58aCRA9TVsSAnZWagAAELAP/3fWY073G5ESg3EuU2QX\nxMOnmYgsL6xHkvbQO0o3YMRHR46kj9GxzlLto32Z4H3+dQJ36Yzsazf3NFa5\nRlVwax2eT/8PREW0Gs71TGXeZxydklzKpOyVAIwwuMuGoqMgIAW8D+FGQCOB\nFIGpEeqDycdTth8Kwjga5lKlF7ZucQAw9G29NtGpEV2w8DduZX6nTGM7z1dd\npGjNzrwG7keXr7wClyuCv1zjxQ3ciUYJ78ybVSx8VYyE6Or7V94P4NEya2ra\n4UhbSndljkqcQ9v1EVtbAvwQx8Zj2tclq4NksamhLyRcWkCgd4zy72yP8B4C\n4wXQzIdXqns2+grAm+T9FGVEnXgu3LJF14qNIWs0bWKPgHEgL93oGUvBy0sD\nwN+0VxeZaJgoUJyqNA/R5iqb2oxqazlkgUZQxBnqHp65318oPCuL4DBbNtYW\nm57JFr3zYRcwz1YYoOCTzUIUIsIiQ/KQPmuRf8lvcQgjvj4GJ5GBNhgqInyR\n7jj6aN/UzfBo9EoQSSf5IW7L3LjUTYwHVv5cY9MYbOcTkNDiDEdVgibYgd2T\nSWsaXYi+rvjJGVPV7/77KES1wDfPsQG2Iq51ax5F8UwKGtzyLcmbs/2XKd2Y\nurQIpGAmXCbi5RLtkI0CefX3Mzrh7dSil78lT/mWK9Dq0+SvqEY8AT3p1CpC\nYwl8\r\n=SZV6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHSBOitXnTfxUUENKcHRpsAvZKcMlw5BLTTmr13W/aQAIgARZnTWA7sTiaU1jv3ZSlM/EzjEwuAozIUykAIdrFcGA="}]},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-on_0.0.3_1624219418399_0.18350458112793633"},"_hasShrinkwrap":false},"0.1.0":{"name":"@antoniovdlc/await-on","version":"0.1.0","description":"Go-like error handling for async JavaScript functions (and more).","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"jest","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["async","await","await-on","error","handling","promise"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/await-on.git"},"bugs":{"url":"https://github.com/AntonioVdlC/await-on/issues"},"homepage":"https://github.com/AntonioVdlC/await-on#readme","license":"MIT","devDependencies":{"@babel/core":"^7.14.6","@babel/preset-env":"^7.14.5","@babel/preset-typescript":"^7.14.5","@rollup/plugin-typescript":"^8.2.1","@types/jest":"^26.0.23","babel-jest":"^27.0.2","eslint":"^7.29.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jest":"^24.3.6","husky":"^6.0.0","jest":"^27.0.4","lint-staged":"^11.0.0","prettier":"^2.3.1","rimraf":"^3.0.2","rollup":"^2.52.1","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.3.4"},"gitHead":"2342f7bd7ce5041d7891b8cc1a3aca9b959d429f","_id":"@antoniovdlc/await-on@0.1.0","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-a1rHuKdzBEq+ffex2dmiUUVDchPIzpjt3cCEv+YNhIBLRdwx0Q05KnBDSmwdtWy6Jh21PlUyHxohQICTkSvBKw==","shasum":"3a0f3cc38a1199737a27bdc7ade891755d228a6b","tarball":"https://registry.npmjs.org/@antoniovdlc/await-on/-/await-on-0.1.0.tgz","fileCount":6,"unpackedSize":11484,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgz7XYCRA9TVsSAnZWagAAWgEP/j+jDQea+wC2HWeyRXkF\nNo6q1oOuNf1MVauzB82dxNPIkUCTyl0Ng+p2BdCxhFNVd9XAqmXMcFONmuo7\nhu/m+5rc5zl4FKMI8Lg/RsgUimQtMNLArJ2ib3rDbGv518pgBPORhmifrGbY\nOqsx79+SoB8HQrScvnecEkgX44SD6IgoVdlOCkejKLwmCGkF1pkYU2Q4j/1x\n6BmOZ77moD6L8atjgI4FMpsfd5JPB/qJPKX3MnjLra3sdG5Vcx9LuQputETh\novCOi3Jnw/8TC2sA1kz62HFrxPDZhUpA06rjQTDsMFGFD7CfkIL7digC7nWo\n/f29APrJ8fqn6MbXMcER8IwGojE15vycXqb0QyhFTb11ZQygt7/Zky6w6XPP\npn6wNNfMe6cuefz2Qeo6xBb4VwWtStQZLS/rHo3YXkBJNfJgjxq0Gx1FRbts\nvfxFPe5DjOmbqxliUodEmsx3jXOmsL25JVVMDhFQ9/ExCxmuBgsTt1/fJPhf\nvtUnehDScb9uDGfm4DvUqY1kSGYFK/fXNKOL5drYTfU4SjrjX+nnP18nFDXc\niLI7/9aXa9LbNVDvi/eJx8TIJ/PTXJ5wVAogm1mxbb5Lc78wGfw45qyMhDpH\ncSnJn1rfrzvMC5xrZZO5JTJibCHB7jU6vfKsozg0mAqUodpqqUAphhDOhVlK\n8oH8\r\n=T8z2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFZrMNsPyTeVn/CQ6LgNXA5BirKGZlJnQNprO+Fl63CLAiADakkgHL7wqSV8KNlWq7hy68bMNHNJvrSAq8Ar83jJ/g=="}]},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-on_0.1.0_1624225240168_0.14136030331109484"},"_hasShrinkwrap":false},"0.1.2":{"name":"@antoniovdlc/await-on","version":"0.1.2","description":"Go-like error handling for async JavaScript functions (and more).","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"jest","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["async","await","await-on","error","handling","promise"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/await-on.git"},"bugs":{"url":"https://github.com/AntonioVdlC/await-on/issues"},"homepage":"https://github.com/AntonioVdlC/await-on#readme","license":"MIT","devDependencies":{"@babel/core":"^7.14.6","@babel/preset-env":"^7.14.5","@babel/preset-typescript":"^7.14.5","@rollup/plugin-typescript":"^8.2.1","@types/jest":"^27.0.1","babel-jest":"^27.0.2","eslint":"^7.29.0","eslint-config-prettier":"^8.3.0","eslint-plugin-jest":"^24.3.6","husky":"^6.0.0","jest":"^27.0.4","lint-staged":"^11.0.0","prettier":"^2.3.1","rimraf":"^3.0.2","rollup":"^2.52.1","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.3.4"},"gitHead":"554464065adf7c7727a019fdb339f5257fd702ec","_id":"@antoniovdlc/await-on@0.1.2","_nodeVersion":"14.17.6","_npmVersion":"6.14.15","dist":{"integrity":"sha512-dudEAXnVlA/dYZh3s/i+lwEbQg7gWfGf0dTqU0ekEKvMJ5TfdBDJ0EBwK0vmt+eav5abbiVPt5uiO9GwwOZVwQ==","shasum":"19624f826595f3e6639c80ab53362b054e361c03","tarball":"https://registry.npmjs.org/@antoniovdlc/await-on/-/await-on-0.1.2.tgz","fileCount":6,"unpackedSize":11487,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhO9RGCRA9TVsSAnZWagAAFrcP/AxquwA/y2mZOqXn82nn\nvySH0B+Bh9CvExGrzGjndPWN5pAlkLb9oenxbz5SO0Ret7YTqfmsu2J52+go\n+VRnt7T8HgNAGClQjAyUDia/JQ2qRxFHGaGN7Vzuxw4nEpR5iuCFKym6bOd2\nc80zdalTAFcnCUglzB++T3xR3CbehRugOsIy2+13ujiszjtViI9nq45i5VzD\nWSYrT43Kyn0wXqGmYtDddERz472P3Sya+z1XJfzVjlNKeLZE0svEM+nAdpx/\n6wkdam0EUs8nN9v9cCKH1r12LU9OafesH0aZ4N0R6etQMMZ6aakGBmNHbkk8\nCL19L59/bZ/A0nczDMScopPB29AI5q5L7grwllC524MZ2b/OnD6fPclb2JYK\nZhDhKylzNrgUn0c6+45u3ZyusabLnYHa0z2iF13/sZaAKOC2sHFwMEQprkw4\npG9ntYcnGjTN0/lmykZixk1V1XWodQpN9OxzE8DCT/eAk+EbO1rzuAXNIvJ9\nuP8kU3yQisqxmANB58PFFUEYEdTgJB5bqjtQB9v6cGctl0Hg19J5XELTgSpX\n69roV1Wtd6rk9u9NulIsKeCLyamIZmLvfgNClQxp0ecC1Id3TEMQG/YE9oPE\nhd1cxROZkWTjPBAjTMEOqvR0Y28Bx3R0sgWcYh6+i8gKv2QjAoWvIe+8Pbup\nb37D\r\n=sZx+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDq4643P3LjXhhT71VOaNNKOPIJR5/K1B5Y0pu7iRBniAiBfpNx118FbdyCMeunlubzp+Q6kLrvsQU7DEmE6eAvMxg=="}]},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-on_0.1.2_1631310917856_0.7602987278381192"},"_hasShrinkwrap":false},"1.0.0":{"name":"@antoniovdlc/await-on","version":"1.0.0","description":"Go-like error handling for async JavaScript functions (and more).","main":"dist/index.cjs.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"prepare":"husky install","type:check":"tsc src/*.ts --noEmit","format":"prettier --write --ignore-unknown {src,test}/*","format:check":"prettier --check {src,test}/*","test":"vitest run --coverage","pre-commit":"lint-staged","prebuild":"rimraf dist && mkdir dist","build":"npm run build:types && npm run build:lib","build:types":"tsc src/*.ts --declaration --emitDeclarationOnly --outDir dist","build:lib":"rollup -c","postversion":"git push && git push --tags"},"keywords":["async","await","await-on","error","handling","promise"],"author":{"name":"Antonio Villagra De La Cruz"},"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/await-on.git"},"bugs":{"url":"https://github.com/AntonioVdlC/await-on/issues"},"homepage":"https://github.com/AntonioVdlC/await-on#readme","license":"MIT","devDependencies":{"@rollup/plugin-typescript":"^8.2.1","c8":"^7.11.0","eslint":"^7.29.0","eslint-config-prettier":"^8.3.0","husky":"^6.0.0","lint-staged":"^11.0.0","prettier":"^2.3.1","rimraf":"^3.0.2","rollup":"^2.52.1","rollup-plugin-terser":"^7.0.2","tslib":"^2.3.0","typescript":"^4.3.4","vite":"^2.9.1","vitest":"^0.9.3"},"gitHead":"546ab2a15366875e5bb4125fa8ef2deeb902c4b3","_id":"@antoniovdlc/await-on@1.0.0","_nodeVersion":"14.19.1","_npmVersion":"6.14.16","dist":{"integrity":"sha512-MxO26uYJSj4fjD6UmtMn5yyCav+NIPHC9sHtmTvZwFjZVMDpl98zmgvsGlxGnUP+L7j59N7q06BXjWzkzhozEQ==","shasum":"99a88faca40211a5d16cbb97c3ec0162b9603aaa","tarball":"https://registry.npmjs.org/@antoniovdlc/await-on/-/await-on-1.0.0.tgz","fileCount":6,"unpackedSize":11417,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDAyUx5klhiv0sPdVvwUscw9IQh5K6v2cz/YeMBJFRCZAIhAPlVCfsKaLuVlEuLzDCW5Y6KU95LXao2rCgtJkMdjKCQ"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiVACyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmobrxAAlnUJSCKKOnDuGj9Xrdw4eslh8c/bQMCvVkKV4Bc7pwpawF5O\r\nI72zB6HI719LbKCPmOdmWWQycjhxJanVYDARSYqMC2rt/qKX2sEj4vtDoN9K\r\npiKXhHNlRordnIMGizYYYhkcQnpgJOZCNJYOT8MM2VFEn30CLibA5KGtwtl4\r\ndsiAfGXBaXukgpmUPPRbabV2Dt2VNzotmG6fw9hFR66FEqdYrW0ziFMiuXkt\r\nLV039pf7FxNMrWwIjIz2J9qfT4DlyVwNunnhl8ACAHV6sn3Bm29SQTxSMdsX\r\n+IyvAWPrlLpRyLJ/sdAaYbUk+FHmHOpH1d9tIgGdZmcNa2/J9q1FN/VjgyC6\r\n80WHub7T04tzEwEpPe3TX4q7MhcMryqp5LTioBUuEM+iVgwzLANJLlo+D28I\r\nbsVj6q15RmMPgzm3Js6nIkhor2OFTNxr8un6KBJCIfAdEQIhtjBYi2P7ID0V\r\n2F8/c9n1lsof2/HIATIMmW1XrN03ZJpXukdbG9N6vtQWo0oNNgO4HceOOmzp\r\nbkCjGfNDWNPOiKeyrdlcKY/p4Lar9g+F7PwZAqp9/UfN3DLKYaAc+RP48ihl\r\nxDM+vQDfBbw7y4NCmrRtgJ0rh0MRs1vKHX/eYNs7byVq6bgSOhC/nx2S/g5F\r\n7YhMh0RWt9+Nmo6nxmtYcfX7+owr7DWJKFw=\r\n=a/XO\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"},"directories":{},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/await-on_1.0.0_1649672369964_0.9112466320986135"},"_hasShrinkwrap":false}},"time":{"created":"2021-06-20T20:03:38.354Z","0.0.3":"2021-06-20T20:03:38.516Z","modified":"2022-04-11T10:19:30.161Z","0.1.0":"2021-06-20T21:40:40.298Z","0.1.2":"2021-09-10T21:55:18.014Z","1.0.0":"2022-04-11T10:19:30.103Z"},"maintainers":[{"name":"antoniovdlc","email":"antonio.villagra.de.la.cruz@gmail.com"}],"homepage":"https://github.com/AntonioVdlC/await-on#readme","keywords":["async","await","await-on","error","handling","promise"],"repository":{"type":"git","url":"git+https://github.com/AntonioVdlC/await-on.git"},"author":{"name":"Antonio Villagra De La Cruz"},"bugs":{"url":"https://github.com/AntonioVdlC/await-on/issues"},"license":"MIT","readme":"# await-on\n\n[![version](https://img.shields.io/npm/v/@antoniovdlc/await-on.svg)](http://npm.im/@antoniovdlc/await-on)\n[![issues](https://img.shields.io/github/issues-raw/antoniovdlc/await-on.svg)](https://github.com/AntonioVdlC/await-on/issues)\n[![downloads](https://img.shields.io/npm/dt/@antoniovdlc/await-on.svg)](http://npm.im/@antoniovdlc/await-on)\n[![license](https://img.shields.io/npm/l/@antoniovdlc/await-on.svg)](http://opensource.org/licenses/MIT)\n\nGo-like error handling for async JavaScript functions.\n\n## Installation\n\nThis package is distributed via npm:\n\n```\nnpm install @antoniovdlc/await-on\n```\n\n## Motivation\n\nAsync functions in JavaScript are great! They allow you to write asynchronous code as if it were synchronous. \n\nThe main drawback I personally experience is having to write code like this:\n```js\ntry {\n  const result = await someFunc()\n  // Do something with `result`\n} catch (err) {\n  // Handle error\n}\n```\n\nHaving had some past experience using Go, and after some time to fully understand the elegance of its simplistic error handling approach, it felt right to try to replicate it:\n```go\nresult, err := someFunc();\nif err != nil {\n  // Handle error\n}\n// Do something with `result`\n```\n\nThis is why this package exists, so that we can write asynchronous JavaScript code in a style as close as possible to that of Go:\n```js\nconst [result, err] = await on(someFunc)\nif (err != null) {\n\t// Handle error\n}\n// Do something with `result`\n\n```\n\n## Usage\n\nYou can use this library either as an ES module or a CommonJS package:\n```js\nimport on from \"@antoniovdlc/await-on\";\n```\n*- or -*\n```js\nconst on = require(\"@antoniovdlc/await-on\");\n```\n\nThe return is formatted as follow:\n\n```js\nconst [result, error] = await on(someFunc)\n```\n\nIn the case where `someFunc()` throws an error, the function call will return `[null, error]`, else, it will return the computed `result` and `error` will be `null`.\n\nYou can pass the following arguments to `on()`:\n- T\n- Promise<T>\n- Function\n- Array<Promise<T> | Function>\n\n## Examples\n\nThe following examples always populate `result` with the value `42` and `error` with `null`:\n```js\nconst value = 42;\nconst [result, error] = await on(value);\n```\n```js\nconst promise = new Promise(resolve => resolve(42));\nconst [result, error] = await on(promise); \n```\n```js\nconst fn = () => 42;\nconst [result, error] = await on(fn); \n```\n\nThe following examples always set `result` to `null` and `error` to an `Error`:\n```js\nconst someError = new Error(\"Some Error\");\nconst [result, error] = await on(someError);\n```\n```js\nconst promise = new Promise((_, reject) => reject(\"Some Error\"));\nconst [result, error] = await on(someError);\n```\n```js\nconst someError = new Error(\"Some Error\");\nconst fn = () => {\n  throw someError;\n};\nconst [result, error] = await on(fn);\n```\n  \nAs an extra goodie, you can also pass an `Array`:\n```js\nconst value = 42;\nconst promise = new Promise(resolve => resolve(42));\nconst fn = () => 42;\n\nconst [result, error] = await on([promise, fn, value]);\nconsole.log(result); // [42, 42, 42]\n```\nYou can even go into destructuring overdrive!\n```js\nconst [[r1, r2], error] = await on([promise1, promise2])\n```\n> Note that the whole call to `on()` will return an `error` if one of the elements of the Array either throws or rejects.\n\n## Previous Art\n\nBesides getting inspiration from Go's error handling, this package also draws inspiration from the following packages:\n- [await-to-js](https://www.npmjs.com/package/await-to-js)\n- [await-on](https://www.npmjs.com/package/await-on)\n- ... and many more!\n  \n## FAQ\n  \n### Why not use any of the existing packages?\n\nGood you ask! \n\nThere is probably a bit of selfishness in the belief that maybe I can implement this in a better way, but the main reason is to see if I can implement such a library and maybe add some goodies on top.\n\nThis code, even though thoroughly tested with 100% code coverage, has not ran in production yet. As such, either you feel adventurous, or I would invite you to look for more mature libraries providing essentially the same functionalities (I've linked to a few I found myself right above, but there are many more).\n\nAnyway, thanks for stopping by! :)\n \n### Why returning an Array and not an Object?\n  \nPretty much for the same reason React hooks (and many other libraries) return an Array (most of the time) and not an Object: it gives you the ability to name the destructured variables as you please!\n\n## License\nMIT","readmeFilename":"README.md","description":"Go-like error handling for async JavaScript functions (and more)."}