JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 708
  • Score
    100M100P100Q95326F
  • License MIT

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][].

Package Exports

  • try-catch-callback

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (try-catch-callback) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

try-catch-callback npmjs.com The MIT License npm downloads

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.

code climate standard code style travis build status coverage status dependency status

Install

npm i try-catch-callback --save

Usage

For more use-cases see the tests

const tryCatchCallback = require('try-catch-callback')

tryCatchCallback

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.

Params

  • <fn> {Function}: function to be called.
  • [cb] {Function}: callback with cb(err, res) signature.
  • returns {Function} thunk: if cb not given.
  • throws {TypError} if fn not a function.
  • throws {TypError} if no function is passed to thunk.

Example

var tryCatch = require('try-catch-callback')

tryCatch(function () {
  return 'fox qux'
}, function done (err, res) {
  if (err) return console.error(err)
  console.log(res) // => 'fox qux'
})

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github