Object.keys = Object.keys || function keys(object) {
if(object === null || object === undefined){
throw new TypeError('Cannot convert undefined or null to object');
}
let result = []
if(isArrayLike(object) || isPlainObject(object)){
for (let key in object) {
object.hasOwnProperty(key) && ( result.push(key) )
}
}
return result
}
Object.values = Object.values || function values(object) {
if(object === null || object === undefined){
throw new TypeError('Cannot convert undefined or null to object');
}
let result = []
if(isArrayLike(object) || isPlainObject(object)){
for (let key in object) {
object.hasOwnProperty(key) && ( result.push(object[key]) )
}
}
return result
}
let result = Objext.keys(list).map(item => {
return {
text: item,
children: Object.values(list[item])
}
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…