{"name":"try-to-catch","version":"1.1.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":"tape 'test/*.js'","watch:test":"nodemon -w lib -w test -x \"npm test\"","lint":"eslint lib test","coverage":"nyc npm test","report":"nyc report --reporter=text-lcov | coveralls","build":"babel lib -d legacy","wisdom":"redrun build legacy","legacy":"echo \"module.exports = require('./try-to-catch')\" > legacy/index.js"},"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":"^5.6.0","nodemon":"^1.14.12","nyc":"^13.0.1","redrun":"^7.0.2","tape":"^4.8.0","try-to-tape":"^1.0.0"},"license":"MIT","gitHead":"dba8906466a52c51b7471e7c05c363a76fb899a6","bugs":{"url":"https://github.com/coderaiser/try-to-catch/issues"},"_id":"try-to-catch@1.1.1","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"dist":{"integrity":"sha512-ikUlS+/BcImLhNYyIgZcEmq4byc31QpC+46/6Jm5ECWkVFhf8SM2Fp/0pMVXPX6vk45SMCwrP4Taxucne8I0VA==","shasum":"770162dd13b9a0e55da04db5b7f888956072038a","tarball":"http://registry-npm.ywwl.com/try-to-catch/download/try-to-catch-1.1.1.tgz","fileCount":7,"unpackedSize":6649,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb5JL7CRA9TVsSAnZWagAA8dMP/jvxqn4RYQYkFlKdkwg4\nhtIpw91w4P992BaFeeaF2i+iOs3qnxgDh+Ur+xXGPksmICQn2vZHERq2Gl2U\neH5b2avm14iQXy9jxmiJG8eoVYICJN91w85YuB2+iOeMsbwH4e16jEDGeCgd\nl/ZubsgM9/Qj2qXB0CKtLP5XrTVsHRG37/wzBnAu5HPFoflMHWF9a+kpDcmf\nd3bU3mOd5UvjQwpi8TiN9GkpcvOiTMmG4UtRFbhhM1P310E+0xuAhsFDb0cK\nVaVSgQ1WocYo6RDYyByD0IZgSRYuXhTHMj/XDI+U/RhaBWorcDxtr6nA07cP\nIa0ldzyWvXUBMfJxTwBNHolkeTRUmZsRV4tHnZLZLBVUZbytc6mNyp1M1Apf\nLbu8jaqlhjwGwVlJgua8TnOExQisHPI7fxykaudoTlr1NYmSsKpbOcum2GPb\nDAxOkRln6t7Y/VKTpczQXS5L6TFXlIjxXl3WDudJHsDsX/C7YapHW/3K7kke\nLE4wYqukuvYuZXwK7XTVW04Cf2HUUIm8dxysFfC4Pgt0a4OdVCX900KVZriV\nhH9/kAkpcop0yQJiqZF2kqncM0FRmojDuIY5A/eSezWKUPlLBg6N9GmrP+CV\nRy4yqzsNm7qnzfrlZImyCnhfE/kz2I45GJwXktfzif9B39QAoGVOiC9JqPi1\nX8GP\r\n=WlCP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD3Pg1f7wCsnrgBiJ7J5QEz2pdkumavXtzA7Zf1QQMidgIhAPVWG5ol+T6H6zO6laenrJP3vh4l5rp9FZGIT8RSZrNK"}],"size":2994,"noattachment":false,"key":"/try-to-catch/-/try-to-catch-1.1.1.tgz"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/try-to-catch_1.1.1_1541706491158_0.75607698209243"},"_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":1541706491283,"_cnpm_publish_time":1541706491283,"dist-tags":{"latest":"4.1.0"}}