tryit.js 257 B

1234567891011121314
  1. // tryit
  2. // Simple, re-usuable try-catch, this is a performance optimization
  3. // and provides a cleaner API.
  4. module.exports = function (fn, cb) {
  5. var err;
  6. try {
  7. fn();
  8. } catch (e) {
  9. err = e;
  10. }
  11. if (cb) cb(err || null);
  12. };