builderman verion 0.1.0, initial commit/release.
This commit is contained in:
17
node_modules/try-to-catch/lib/try-to-catch.js
generated
vendored
Normal file
17
node_modules/try-to-catch/lib/try-to-catch.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = async (fn, ...args) => {
|
||||
check(fn);
|
||||
|
||||
try {
|
||||
return [null, await fn(...args)];
|
||||
} catch(e) {
|
||||
return [e];
|
||||
}
|
||||
};
|
||||
|
||||
function check(fn) {
|
||||
if (typeof fn !== 'function')
|
||||
throw Error('fn should be a function!');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user