Skip to content

Commit 7f3c4f5

Browse files
committed
feat: add util for converting array to boolean key, value
1 parent bfa607a commit 7f3c4f5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Shared/Helpers.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,12 @@ export const getWebhookEventIcon = (eventName: WebhookEventNameType) => {
103103
}
104104

105105
export const isNullOrUndefined = (value: unknown): boolean => value === null || value === undefined
106+
107+
export const getKeyToBooleanMapFromArray = <T extends string | number>(arr: T[] = []) =>
108+
arr.reduce<Record<T, boolean>>(
109+
(acc, key) => {
110+
acc[key] = true
111+
return acc
112+
},
113+
{} as Record<T, boolean>,
114+
)

0 commit comments

Comments
 (0)