GitHub

daffArrayToDict

Helper

import { daffArrayToDict } from '@daffodil/core'

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

function daffArrayToDict<T, R extends keyof Dictionary = keyof Dictionary>(
  array: T[]
  getKey: (val: T) => R
): Record<R, T>

Parameters

Parameterarray: T[]
Description
ParametergetKey: (val: T) => R
Description