{"_id":"@badnoodles/eav","_rev":"2-55da5ce57a08b0a5eb6c30cbe8877300","name":"@badnoodles/eav","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@badnoodles/eav","version":"0.0.1","keywords":["error","try","catch","value"],"author":{"name":"Rafael Pinheiro"},"license":"ISC","_id":"@badnoodles/eav@0.0.1","maintainers":[{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"}],"homepage":"https://github.com/bad-noodles/eav#readme","bugs":{"url":"https://github.com/bad-noodles/eav/issues"},"dist":{"shasum":"4b662af4e3bec4214178623ef6991eab0540ba37","tarball":"https://registry.npmjs.org/@badnoodles/eav/-/eav-0.0.1.tgz","fileCount":9,"integrity":"sha512-o6BrxntwzV2nzge940nxwYYYAEoYKoyN8hzgr/crmBSmDuWt+9n4S4NwnOojgwxbRPajPZztNfifmDWU+pJ5ug==","signatures":[{"sig":"MEQCICmWy3sMBRmCoEJsactQCka8XqT0dH9xQzZGzGlVp3HHAiA4cXt0OXv3oCtLtftDZPMJV0duV0pSU36VY8fJkQA5ag==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18430},"main":"dist/index.js","types":"./dist/index.d.ts","gitHead":"8c9fabef44e6b2231aca2d3b42245aceffd8a3d4","scripts":{"test":"jest dist","build":"rimraf dist && tsc"},"_npmUser":{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"},"repository":{"url":"git+https://github.com/bad-noodles/eav.git","type":"git"},"_npmVersion":"10.7.0","description":"Helper to use an error as value approach in javascript and typescript","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/eav_0.0.1_1721249961731_0.23117488000073072","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@badnoodles/eav","version":"0.0.2","keywords":["error","try","catch","value"],"author":{"name":"Rafael Pinheiro"},"license":"ISC","_id":"@badnoodles/eav@0.0.2","maintainers":[{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"}],"homepage":"https://github.com/bad-noodles/eav#readme","bugs":{"url":"https://github.com/bad-noodles/eav/issues"},"dist":{"shasum":"5d999ea136a9322facc26e8437dec80601e73e4b","tarball":"https://registry.npmjs.org/@badnoodles/eav/-/eav-0.0.2.tgz","fileCount":9,"integrity":"sha512-2w8SBC3hvrpTox1k8bVRmIZCeffY4HSQo5BiYXzYffLtfZsxTn5muqQayN6T09DHspVIVXATd+lJRw9DCh+vKQ==","signatures":[{"sig":"MEQCIAtbpAJKH2WV7CaqJ6zlNJf+3ZCoT+/zok1tllQkylJMAiBGYW+oSfrv8JKzqOKZKx4Ow1JE2ddjocZdxmay4HV9jQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18454},"main":"dist/index.js","types":"./dist/index.d.ts","gitHead":"1215bdf2f7a1461f69c61c31e235801be58fc7b8","scripts":{"test":"jest dist","build":"rimraf dist && tsc"},"_npmUser":{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"},"repository":{"url":"git+https://github.com/bad-noodles/eav.git","type":"git"},"_npmVersion":"10.7.0","description":"Helper to use an error as value approach in javascript and typescript","directories":{},"_nodeVersion":"22.2.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","rimraf":"^6.0.1","typescript":"^5.5.3","@types/jest":"^29.5.12"},"_npmOperationalInternal":{"tmp":"tmp/eav_0.0.2_1721255432631_0.22853755568098477","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@badnoodles/eav","version":"0.0.3","description":"Helper to use an error as value approach in javascript and typescript","main":"dist/index.js","scripts":{"test":"jest dist","build":"rimraf dist && tsc"},"keywords":["error","try","catch","value"],"author":{"name":"Rafael Pinheiro"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/bad-noodles/eav.git"},"devDependencies":{"@types/jest":"^29.5.12","jest":"^29.7.0","rimraf":"^6.0.1","typescript":"^5.5.3"},"_id":"@badnoodles/eav@0.0.3","gitHead":"0556cb8846d23a90747c6f71d709bc8be29a991a","types":"./dist/index.d.ts","bugs":{"url":"https://github.com/bad-noodles/eav/issues"},"homepage":"https://github.com/bad-noodles/eav#readme","_nodeVersion":"22.2.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-rMbDn1eDUJX71z6jqsuRqqIzc/Rs//uJqKGMh0zZ2qmJ+VEbhlpSdC4bavAvicI4rBB5AmjJW5m5SO4eM5c8ww==","shasum":"8373e952bcdf0c94959090563d03d2e04ec51513","tarball":"https://registry.npmjs.org/@badnoodles/eav/-/eav-0.0.3.tgz","fileCount":9,"unpackedSize":18562,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAqadehb4sXRecf9yiG/kKDPkGBr4RiEXAciuZ0Z3QePAiEA0/DcYCSWo6bXhYNRcgTl/Vaj13jcXtc7Qv0GNUQSeo8="}]},"_npmUser":{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"},"directories":{},"maintainers":[{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eav_0.0.3_1721255653096_0.4330627113199057"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-17T20:59:21.634Z","modified":"2024-07-17T22:34:13.474Z","0.0.1":"2024-07-17T20:59:21.891Z","0.0.2":"2024-07-17T22:30:32.841Z","0.0.3":"2024-07-17T22:34:13.285Z"},"bugs":{"url":"https://github.com/bad-noodles/eav/issues"},"author":{"name":"Rafael Pinheiro"},"license":"ISC","homepage":"https://github.com/bad-noodles/eav#readme","keywords":["error","try","catch","value"],"repository":{"type":"git","url":"git+https://github.com/bad-noodles/eav.git"},"description":"Helper to use an error as value approach in javascript and typescript","maintainers":[{"name":"bad-noodles","email":"pinheiro.rbp@gmail.com"}],"readme":"# EAV\n\n<!--toc:start-->\n- [EAV](#eav)\n  - [Error As Value](#error-as-value)\n  - [Why?](#why)\n  - [Usage](#usage)\n<!--toc:end-->\n\n## Error As Value\n\neav is a simple helper to follow an error as value approach instead the try/catch native Javascript approach.\nThe implementation is heavily inspired by how errors are treated in Go.\nArray destructuring is expect to be used as a way to simulate multiple return values.\n\n## Why?\n\nThe try/catch approach creates an extra layer of scope that is often weird to deal with, making you add extra\nindentation or use let variables to continue with your logic after the try/catch logic.\n\n## Usage\n\n```Typescript\nimport { eav } from '@badnoodles/eav'\n\nconst [v, err] = await eav<string>(() => Promise.resolve(\"value\"))\n\nif (err) {\n  console.error(err)\n  /**\n   * The if + return will enable typescript's type narrowing\n   * Comment out the return to see typescript complaining about the type of `v`\n   * being possibly null on the console log below\n   */\n  return\n}\n\nconsole.log(v.endsWith(\"ue\"))\n```\n\nCheck [the tests](https://github.com/bad-noodles/eav/blob/main/src/index.test.ts) for more usage examples.\n","readmeFilename":"Readme.md"}