const destructo = require('destructo')
const target = {
username: 'JohnDoe',
password: 'secret',
id: 100
}
const personDetails = destructo(target, 'username', 'id')
console.log(personDetails)
const target = {
someKey: 'someValue',
deep: {
foo: 'deepFoo'
}
}
const newKeyNames = destructo(target, 'someKey:newName', 'deep.foo:newFoo')
console.log(newKeyNames)
const target = {
someKey: 'someValue',
deep: {
foo: 'deepFoo',
bar: 'deepBar',
}
}
const deep = destructo(target, 'deep.foo', 'deep.bar')
console.log(deep)
const someList = [
{name: 'Lassie', 'animalType': 'dog', color: 'brown'},
{name: 'CatStevens', 'animalType': 'cat', color: 'yellow'},
{name: 'Christian', 'animalType': 'lion', color: 'orange'}
]
const nameAndColor = someList.map(animal => destructo(animal, 'name', 'color'))
console.log(nameAndColor)