GitHub

daffArrayToDict

const

import { daffArrayToDict } from '@daffodil/core'

Converts an array into a dictionary. Dictionary values are keyed by the return of the specified getKey.

const daffArrayToDict: <T, R extends string | number | symbol = string | number | symbol>(array: T[], getKey: (val: T) => R) => Record<R, T>