Radash
  1. Object
  2. listify

Basic usage

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

import { listify } from 'radash'

const fish = {
  marlin: {
    weight: 105,
  },
  bass: {
    weight: 8,
  }
}

listify(fish, (key, value) => ({ ...value, name: key })) // => [{ name: 'marlin', weight: 105 }, { name: 'bass', weight: 8 }]