aswi2020vldc-gitlab/templetes/node_modules/nice-try/src/index.js @ 143404cb
1 | 3a515b92 | cagy | 'use strict' |
---|---|---|---|
2 | |||
3 | /**
|
||
4 | * Tries to execute a function and discards any error that occurs.
|
||
5 | * @param {Function} fn - Function that might or might not throw an error.
|
||
6 | * @returns {?*} Return-value of the function when no error occurred.
|
||
7 | */
|
||
8 | module.exports = function(fn) { |
||
9 | |||
10 | try { return fn() } catch (e) {} |
||
11 | |||
12 | }
|