Object
Flattens a deep object to a single dimension
Flattens a deep object to a single dimension. The deep keys will be converted to a dot notation in the new object.
import { crush } from 'radash'
const ra = {
name: 'ra',
power: 100,
friend: {
name: 'loki',
power: 80
},
enemies: [
{
name: 'hathor',
power: 12
}
]
}
crush(ra)
// {
// name: 'ra',
// power: 100,
// 'friend.name': 'loki',
// 'friend.power': 80,
// 'enemies.0.name': 'hathor',
// 'enemies.0.power': 12
// }