{"name":"try-to-catch","version":"2.0.1","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"function try-catch wrapper for promises","homepage":"http://github.com/coderaiser/try-to-catch","main":"lib/try-to-catch.js","repository":{"type":"git","url":"git://github.com/coderaiser/try-to-catch.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{},"keywords":["try","catch","function","promise","async","await","try-catch","then"],"devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/preset-env":"^7.0.0","coveralls":"^3.0.0","eslint":"^6.1.0","eslint-plugin-node":"^11.0.0","eslint-plugin-putout":"^3.0.0","madrun":"^5.4.0","nodemon":"^2.0.2","nyc":"^15.0.0","putout":"^7.3.4","supertape":"^1.2.4"},"engines":{"node":">=6"},"license":"MIT","gitHead":"10de68440146c013af84dc275b544850929b435e","bugs":{"url":"https://github.com/coderaiser/try-to-catch/issues"},"_id":"try-to-catch@2.0.1","_nodeVersion":"13.5.0","_npmVersion":"6.12.1","dist":{"integrity":"sha512-QYH/PR3ogChy82e2l1UgrEgutcf6Jtfu3TAQWC+Vs6MKpoaFs1atDHUPzfaERugZlESb2Xku7J2my6iUQ7+tcQ==","shasum":"4a943ba6f2921bd3ba945ea5d4459119ec3ec079","tarball":"http://registry-npm.ywwl.com/try-to-catch/download/try-to-catch-2.0.1.tgz","fileCount":5,"unpackedSize":5460,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeCgkxCRA9TVsSAnZWagAAUOYP/RhRu95hBHgjKti7Ohig\nxtN6DQJE0y2itn9yh63GesFkoR9dujdHOFC7HPitYowJ317iOZaTN42Yo68u\nIOs9AGId2vAsQHM+z0QWSecALgJVqWqHo6zh6D2NqejzNNIO3lwigLk6J4oQ\n7jv2tFgruJ+c6catrEBO2bvC0iPvaVIbs4kBwylkTuLRHQH05FffA4zYnLr3\nZmI5QqIcla6zVOvQHs+3sz39/bZk/+JsTQLzJIDuokY6gNrLz1XRe1Y7KP2C\nXV0A9qMKDFWkiPFVPX5ww5HnZOzIsO1w43BWqXRTf6xfd1q9FPv/zU/qi31b\nzbqq3OcxVKUvspzrGzEvPzv9E0bF5rLWlCVdpEfjj3iJPyU5dq3TcOLhJTBZ\nXlxv6NEJ5WhpIcIks5Q2qnoM9OessRDEPmb5X/fFUGkFE9knbCAYLRkbdLKD\ndsKkWIuSyn3I+iGDSvrQH6FsIV7zNlMIbxziG51Ye72+AoIB1V1Yds+yrKI+\n3ZfIvh/qsT2LhtIIFS+0E6CI5sOcjsCJDUZu/RzqbyIWpLNH3eCVNT58iz3Z\nKNftQUFTJ8g+kUju9IEMblBMNLVvb1M56iQG+DBuAsM/cvv66+u4oUBgEIBx\nS8ffK+umCheC3XNf7LVPWncayKDVJPLO+Hr4fSO2GeS/O5afph1NFbXEgHkH\nkKc9\r\n=Id8S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/wFAqIZXhF06Ag41gqCocZ+9En6t8qAWjEOQHspUxwgIgHskW/IUhw6Ig1bpH3Q/yL13g7TfpKNs6JPRK3zziDsY="}],"size":2480,"noattachment":false,"key":"/try-to-catch/-/try-to-catch-2.0.1.tgz"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/try-to-catch_2.0.1_1577716017086_0.6501558536579823"},"_hasShrinkwrap":false,"readme":"# Try to Catch [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/try-to-catch.svg?style=flat&longCache=true\n[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/try-to-catch/master.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/try-to-catch \"npm\"\n[BuildStatusURL]: https://travis-ci.org/coderaiser/try-to-catch \"Build Status\"\n[CoverageURL]: https://coveralls.io/github/coderaiser/try-to-catch?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/try-to-catch/badge.svg?branch=master&service=github\n\nFunctional `try-catch` wrapper for `promises`.\n\n## Install\n\n```\nnpm i try-to-catch\n```\n\n## API\n\n### tryToCatch(fn, [...args])\n\nWrap function to avoid `try-catch` block, resolves `[error, result]`;\n\n### Example\n\nSimplest example with `async-await`:\n\n```js\nconst tryToCatch = require('try-to-catch');\nconst reject = Promise.reject.bind(Promise);\nawait tryToCatch(reject, 'hi');\n// returns\n// [ Error: hi]\n```\n\nCan be used with functions:\n\n```js\nconst tryToCatch = require('try-to-catch');\nawait tryToCatch(() => 5);\n// returns\n[null, 5];\n```\n\nAdvanced example:\n\n```js\nconst {readFile, readdir} = require('fs/promises');\nconst tryToCatch = require('try-to-catch');\n\nread(process.argv[2])\n    .then(console.log)\n    .catch(console.error);\n\nasync function read(path) {\n    const [error, data] = await tryToCatch(readFile, path, 'utf8');\n    \n    if (!error)\n        return data;\n    \n    if (error.code !== 'EISDIR')\n        return error;\n    \n    return await readdir(path);\n}\n```\n\n## Related\n\n- [try-catch](https://github.com/coderaiser/try-catch \"try-catch\") - functional try-catch wrapper.\n\n## License\n\nMIT\n","publish_time":1577716017192,"_cnpm_publish_time":1577716017192,"dist-tags":{"latest":"4.1.0"}}