Convert an object to a list, mapping each entry into a list item
const fish = { marlin: { weight: 105, }, bass: { weight: 8, }}listify(fish, (key, value) => ({ ...value, name: key })) // => [{ name: 'marlin', weight: 105 }, { name: 'bass', weight: 8 }] Copy
const fish = { marlin: { weight: 105, }, bass: { weight: 8, }}listify(fish, (key, value) => ({ ...value, name: key })) // => [{ name: 'marlin', weight: 105 }, { name: 'bass', weight: 8 }]
Description
Convert an object to a list, mapping each entry into a list item
Example