Skip to content

listify

Convert an object to a list

145 bytes

Usage

Given an object and a mapping function, return an array with an item for each entry in the object.

import * as _ from 'radashi'
const fish = {
marlin: {
weight: 105,
},
bass: {
weight: 8,
},
}
_.listify(fish, (key, value) => ({ ...value, name: key })) // => [{ name: 'marlin', weight: 105 }, { name: 'bass', weight: 8 }]