tryor.js 333 B

1234567891011121314151617
  1. // tryor.js
  2. // MIT licensed, see LICENSE file
  3. // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
  4. function tryor(fn, v) {
  5. "use strict";
  6. try {
  7. return fn();
  8. } catch (e) {
  9. return v;
  10. }
  11. };
  12. if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
  13. module.exports = tryor;
  14. }