{"name":"try-catch-callback","version":"1.1.2","description":"try/catch block with a callback, used in [try-catch-core][]. Use it when you don't care about asyncness so much and don't want guarantees. If you care use [try-catch-core][].","repository":{"type":"git","url":"git+https://github.com/hybridables/try-catch-callback.git"},"author":{"name":"Charlike Mike Reagent","email":"@tunnckoCore","url":"http://www.tunnckocore.tk"},"precommit.silent":true,"main":"index.js","license":"MIT","scripts":{"lint":"standard --verbose","pretest":"npm run lint","test":"npm run coverage","posttest":"npm run lint:coverage","coverage":"nyc node test.js","lint:coverage":"nyc check-coverage --lines 100 --branches 100 --statements 100 --functions 100","report-coverage":"nyc report --reporter=text-lcov | coveralls","prerelease":"npm test","release":"standard-version --sign --no-verify","precommit":"git add --all","commit":"git-cz"},"dependencies":{},"devDependencies":{"commitizen":"^2.8.6","coveralls":"^2.11.12","cz-conventional-changelog":"^1.2.0","mukla":"^0.4.1","nyc":"^8.1.0","pre-commit":"^1.1.3","standard":"^8.1.0","standard-version":"^2.4.0"},"files":["index.js"],"keywords":["async","block","callback","catch","cb","core","try","try-catch-callback","trycatch"],"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"verb":{"run":true,"toc":false,"layout":"empty","tasks":["readme"],"related":{"list":["try-catch-core","gana","gana-compile","try-require-please","catchup"]},"reflinks":["dezalgo","once","try-catch-core","es6-template","gana","gana-compile"],"lint":{"reflinks":true}},"gitHead":"157ad9fdb33fc93f56d2b7dfcc0f8dc2656ffb3f","bugs":{"url":"https://github.com/hybridables/try-catch-callback/issues"},"homepage":"https://github.com/hybridables/try-catch-callback#readme","_id":"try-catch-callback@1.1.2","_shasum":"b207542bfd87a2f888a0a4032a8bd1f6ebaaa13e","_from":".","_npmVersion":"4.0.1","_nodeVersion":"7.0.0","_npmUser":{"name":"tunnckocore","email":"mameto_100@mail.bg"},"dist":{"shasum":"b207542bfd87a2f888a0a4032a8bd1f6ebaaa13e","tarball":"http://registry-npm.ywwl.com/try-catch-callback/download/try-catch-callback-1.1.2.tgz","integrity":"sha512-dZEDfOQzQvE6qXnR3ez/VMYrZ1LTpMUKGM7wWzklekzdqNZiPksI0oI2sMDElGzaqZi9QbVHMcV1WwsSzGPAtQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCkSVIdGr1pc7F8/7qhLJg2OnZeQ/VPKyhqY2v+bkkH7AIgbvjNwdQe+Ty0skqEayIM5gr2Brcj3jrvz/JxzaFh/XE="}],"size":5101,"noattachment":false,"key":"/try-catch-callback/-/try-catch-callback-1.1.2.tgz"},"maintainers":[{"name":"tunnckocore","email":"mameto_100@mail.bg"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/try-catch-callback-1.1.2.tgz_1477953206769_0.693593259435147"},"directories":{},"readme":"<p align=\"center\">\n  <a href=\"https://github.com/hybridables\">\n    <img height=\"250\" width=\"250\" src=\"https://avatars1.githubusercontent.com/u/10666022?v=3&s=250\">\n  </a>\n</p>\n\n# try-catch-callback [![NPM version](https://img.shields.io/npm/v/try-catch-callback.svg?style=flat)](https://www.npmjs.com/package/try-catch-callback) [![NPM monthly downloads](https://img.shields.io/npm/dm/try-catch-callback.svg?style=flat)](https://npmjs.org/package/try-catch-callback) [![npm total downloads][downloads-img]][downloads-url]\n\n> try/catch block with a callback, used in [try-catch-core][]. Use it when you don't care about asyncness so much and don't want guarantees. If you care use [try-catch-core][].\n\n[![codeclimate][codeclimate-img]][codeclimate-url] \n[![codestyle][standard-img]][standard-url] \n[![linux build][travis-img]][travis-url] \n[![windows build][appveyor-img]][appveyor-url] \n[![codecov][coverage-img]][coverage-url] \n[![dependency status][david-img]][david-url]\n\n## Install\n```\nnpm i try-catch-callback --save\n```\n\n## Usage\n> For more use-cases see the [tests](./test.js)\n\n```js\nconst tryCatchCallback = require('try-catch-callback')\n```\n\n### [tryCatchCallback](index.js#L47)\n> Pass a synchronous `fn` that returns some result and handle completion or errors in `cb` if given, otherwise it returns thunk which accepts that `cb`. It's possible to not work in \"async mode\", if that's the case try to use [try-catch-core][] for your case, which guarantees that `cb` is called only once and always in next tick, using [dezalgo][] and [once][].\n\n**Params**\n\n* `<fn>` **{Function}**: function to be called.    \n* `[opts]` **{Object}**: optional options, such as `context` and `args`    \n* `[opts.context]` **{Object}**: context to be passed to `fn`    \n* `[opts.args]` **{Array}**: custom argument(s) to be pass to `fn`, given value is arrayified    \n* `[opts.passCallback]` **{Boolean}**: pass `true` if you want `cb` to be passed to `fn` args    \n* `[opts.return]` **{Boolean}**: if `true` returns error/value and does not calls `cb`    \n* `[cb]` **{Function}**: callback with `cb(err, res)` signature.    \n* `returns` **{Function}** `thunk`: if `cb` not given.  \n\n**Example**\n\n```js\nvar tryCatch = require('try-catch-callback')\n\ntryCatch(function () {\n  return 'fox qux'\n}, function done (err, res) {\n  if (err) return console.error(err)\n  console.log(res) // => 'fox qux'\n})\n```\n\n**passing custom context**\n\n```js\nconst tryCatch = require('try-catch-callback')\n\ntryCatch(function () {\n  console.log(this.foo) // => 'bar'\n  console.log(this.baz) // => 'qux'\n  return `${this.foo}/${this.baz}`\n}, {\n  context: { foo: 'bar', baz: 'qux' }\n}, function done (err, res) {\n  if (err) return console.error(err)\n  console.log(res) // => 'bar/qux'\n})\n```\n\n**passing custom arguments**\n\n```js\nconst tryCatchCallback = require('try-catch-callback')\nconst done = (err, res) => console.log(res) // => 'zzz123'\nconst opts = {\n  args: [ { foo: 'zzz' }, 123 ]\n}\n\ntryCatchCallback((ctx, qux) => {\n  return ctx.foo + qux\n}, opts, done)\n\n```\n\n**returning a thunk**\n\n```js\nconst tryCatch = require('try-catch-callback')\nconst thunk = tryCatch((a, b) => {\n  return a + b + 3\n}, { args: [1, 2] })\n\nthunk((err, res) => {\n  console.log(res) // => 6\n})\n```\n\n## Related\n- [catchup](https://www.npmjs.com/package/catchup): Graceful error handling. Because core `domain` module is deprecated. This share almost the same API. | [homepage](https://github.com/tunnckocore/catchup#readme \"Graceful error handling. Because core `domain` module is deprecated. This share almost the same API.\")\n- [gana-compile](https://www.npmjs.com/package/gana-compile): Pretty small synchronous template engine built on ES2015 Template Strings, working on `node@0.10` too. No RegExps, support for helpers and… [more](https://github.com/tunnckocore/gana-compile#readme) | [homepage](https://github.com/tunnckocore/gana-compile#readme \"Pretty small synchronous template engine built on ES2015 Template Strings, working on `node@0.10` too. No RegExps, support for helpers and what you want. Use [gana][] if you wanna both async and sync support.\")\n- [gana](https://www.npmjs.com/package/gana): Small and powerful template engine with only sync and async compile. The mid-level between [es6-template][] and [gana-compile][]. | [homepage](https://github.com/tunnckocore/gana#readme \"Small and powerful template engine with only sync and async compile. The mid-level between [es6-template][] and [gana-compile][].\")\n- [try-catch-core](https://www.npmjs.com/package/try-catch-core): Low-level package to handle completion and errors of sync or asynchronous functions, using [once][] and [dezalgo][] libs. Useful for and… [more](https://github.com/hybridables/try-catch-core#readme) | [homepage](https://github.com/hybridables/try-catch-core#readme \"Low-level package to handle completion and errors of sync or asynchronous functions, using [once][] and [dezalgo][] libs. Useful for and used in higher-level libs such as [always-done][] to handle completion of anything.\")\n- [try-require-please](https://www.npmjs.com/package/try-require-please): Try to require the given module, failing loudly with default message if module does not exists. | [homepage](https://github.com/tunnckocore/try-require-please#readme \"Try to require the given module, failing loudly with default message if module does not exists.\")\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/hybridables/try-catch-callback/issues/new).  \nPlease read the [contributing guidelines](CONTRIBUTING.md) for advice on opening issues, pull requests, and coding standards.  \nIf you need some help and can spent some cash, feel free to [contact me at CodeMentor.io](https://www.codementor.io/tunnckocore?utm_source=github&utm_medium=button&utm_term=tunnckocore&utm_campaign=github) too.\n\n**In short:** If you want to contribute to that project, please follow these things\n\n1. Please DO NOT edit [README.md](README.md), [CHANGELOG.md](CHANGELOG.md) and [.verb.md](.verb.md) files. See [\"Building docs\"](#building-docs) section.\n2. Ensure anything is okey by installing the dependencies and run the tests. See [\"Running tests\"](#running-tests) section.\n3. Always use `npm run commit` to commit changes instead of `git commit`, because it is interactive and user-friendly. It uses [commitizen][] behind the scenes, which follows Conventional Changelog idealogy.\n4. Do NOT bump the version in package.json. For that we use `npm run release`, which is [standard-version][] and follows Conventional Changelog idealogy.\n\nThanks a lot! :)\n\n## Building docs\nDocumentation and that readme is generated using [verb-generate-readme][], which is a [verb][] generator, so you need to install both of them and then run `verb` command like that\n\n```\n$ npm install verbose/verb#dev verb-generate-readme --global && verb\n```\n\n_Please don't edit the README directly. Any changes to the readme must be made in [.verb.md](.verb.md)._\n\n## Running tests\nClone repository and run the following in that cloned directory\n\n```\n$ npm install && npm test\n```\n\n## Author\n**Charlike Mike Reagent**\n\n+ [github/tunnckoCore](https://github.com/tunnckoCore)\n+ [twitter/tunnckoCore](https://twitter.com/tunnckoCore)\n+ [codementor/tunnckoCore](https://codementor.io/tunnckoCore)\n\n## License\nCopyright © 2016-2017, [Charlike Mike Reagent](http://www.tunnckocore.tk). MIT\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on March 01, 2017._  \n_Project scaffolded using [charlike][] cli._\n\n[dezalgo]: https://github.com/npm/dezalgo\n[es6-template]: https://github.com/tunnckocore/es6-template\n[gana-compile]: https://github.com/tunnckocore/gana-compile\n[gana]: https://github.com/tunnckocore/gana\n[once]: https://github.com/isaacs/once\n[try-catch-core]: https://github.com/hybridables/try-catch-core\n\n[downloads-url]: https://www.npmjs.com/package/try-catch-callback\n[downloads-img]: https://img.shields.io/npm/dt/try-catch-callback.svg\n\n[codeclimate-url]: https://codeclimate.com/github/hybridables/try-catch-callback\n[codeclimate-img]: https://img.shields.io/codeclimate/github/hybridables/try-catch-callback.svg\n\n[travis-url]: https://travis-ci.org/hybridables/try-catch-callback\n[travis-img]: https://img.shields.io/travis/hybridables/try-catch-callback/master.svg?label=linux\n\n[appveyor-url]: https://ci.appveyor.com/project/tunnckoCore/try-catch-callback\n[appveyor-img]: https://img.shields.io/appveyor/ci/tunnckoCore/try-catch-callback/master.svg?label=windows\n\n[coverage-url]: https://codecov.io/gh/hybridables/try-catch-callback\n[coverage-img]: https://img.shields.io/codecov/c/github/hybridables/try-catch-callback/master.svg\n\n[david-url]: https://david-dm.org/hybridables/try-catch-callback\n[david-img]: https://img.shields.io/david/hybridables/try-catch-callback.svg\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n[always-done]: https://github.com/hybridables/always-done\n[charlike]: https://github.com/tunnckocore/charlike\n[commitizen]: https://github.com/commitizen/cz-cli\n[standard-version]: https://github.com/conventional-changelog/standard-version\n[verb-generate-readme]: https://github.com/verbose/verb-generate-readme\n[verb]: https://github.com/verbose/verb","publish_time":1477953208704,"_cnpm_publish_time":1477953208704,"dist-tags":{"latest":"2.0.2"}}