UNPKG

@grandlinex/easy-cli

Version:

Cli lib to perform common tasks

37 lines (36 loc) 864 B
export async function StricktOption(option, handler) { if (typeof option === 'function') { return option(handler); } return option; } export async function getBoolOrUndefined(val, fallback = undefined) { let v = val; if (typeof val === 'function') { v = await val(); } if (typeof v === 'boolean') { return v; } return fallback; } export async function getStringOrUndefined(val, fallback = undefined) { let v = val; if (typeof val === 'function') { v = await val(); } if (typeof v === 'string') { return v; } return fallback; } export async function getNumberOrUndefined(val, fallback = undefined) { let v = val; if (typeof val === 'function') { v = await val(); } if (typeof v === 'number') { return v; } return fallback; }