export const buildMapForTrees = ( treeIds: string[], build: (treeId: string) => T ): { [treeId: string]: T } => treeIds .map(id => [id, build(id)] as const) .reduce((a, [id, obj]) => ({ ...a, [id]: obj }), {}); export function preventDefault(e: any) { if (typeof e?.preventDefault === 'function') { e.preventDefault(); } }