array-to-objecthash (master) doxdox documentation

Convert array to object hash based on specific key

# convertArrayToHash(key, data)

converts an array of objects to hashed objects based on the key property of each object const arr = [ { key: 'key_one', value: 'some value one' }, { key: 'key_two', value: 'some value two' } ] const obj = convertArrayToHash(arr, 'key')

Parameters

Name Types Description
key string the key to hash the object upon
data object array