deno.land / x / yargs@v17.6.0-deno / build / lib / utils / maybe-async-result.js

maybe-async-result.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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';}
yargs

Version Info

Tagged at
2 years ago