Tracking de l'application VApp (IHM du jeu)
This commit is contained in:
17
VApp/node_modules/yargs/build/lib/utils/maybe-async-result.js
generated
vendored
Normal file
17
VApp/node_modules/yargs/build/lib/utils/maybe-async-result.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { isPromise } from './is-promise.js';
|
||||
export function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
|
||||
throw err;
|
||||
}) {
|
||||
try {
|
||||
const result = isFunction(getResult) ? getResult() : getResult;
|
||||
return isPromise(result)
|
||||
? result.then((result) => resultHandler(result))
|
||||
: resultHandler(result);
|
||||
}
|
||||
catch (err) {
|
||||
return errorHandler(err);
|
||||
}
|
||||
}
|
||||
function isFunction(arg) {
|
||||
return typeof arg === 'function';
|
||||
}
|
Reference in New Issue
Block a user