use directories for structure
This commit is contained in:
16
node_modules/try-to-catch/lib/try-to-catch.js
generated
vendored
16
node_modules/try-to-catch/lib/try-to-catch.js
generated
vendored
@@ -1,17 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const success = (a) => [null, a];
|
||||
const fail = (a) => [a];
|
||||
|
||||
const noArg = (f, a) => () => f(...a);
|
||||
|
||||
module.exports = (fn, ...args) => {
|
||||
module.exports = async (fn, ...args) => {
|
||||
check(fn);
|
||||
|
||||
return Promise.resolve()
|
||||
.then(noArg(fn, args))
|
||||
.then(success)
|
||||
.catch(fail);
|
||||
try {
|
||||
return [null, await fn(...args)];
|
||||
} catch(e) {
|
||||
return [e];
|
||||
}
|
||||
};
|
||||
|
||||
function check(fn) {
|
||||
|
Reference in New Issue
Block a user