1import { isPromise } from './is-promise.js'; 2export function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => { 3 throw err; 4}) { 5 try { 6 const result = isFunction(getResult) ? getResult() : getResult; 7 return isPromise(result) 8 ? result.then((result) => resultHandler(result)) 9 : resultHandler(result); 10 } 11 catch (err) { 12 return errorHandler(err); 13 } 14} 15function isFunction(arg) { 16 return typeof arg === 'function'; 17} 18