async function catchError(promise: Promise): Promise<[undefined,T] | [Error]> { try { const data = await promise return [undefined, data] as [undefined, T] } catch (error) { return [error] } } export const getUrlParams = (params) => { if (!params) return undefined const url = new URL(window.location.href) const search = Array.isArray(params) ? params : [params] const found = search.map((p) => url.searchParams.get(p)) return found.length === 1 ? found[0] : found } function objectKeyMatch() { const object = { default: function(){}, key: function(){}, } const bella = (object[typeOfAction] || object.default) bella() }