Created
September 17, 2018 06:28
-
-
Save atomize/a756f096292ca9ab5f90e85c1f9b3ba0 to your computer and use it in GitHub Desktop.
Dirty flattener.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function dirtyFlatten(res) { | |
let vals = Object.values(res) | |
vals = vals.map((x) => { | |
return Object.values(x).reduce((a, c) => { | |
if (typeof c === 'object' || typeof c === 'array') { | |
c.map(entry => a.push(entry)) | |
} else { | |
a.push(c) | |
} | |
return a; | |
}, []) | |
}, []).reduce((y, c) => { | |
c.map(entry => y.push(entry)) | |
return y | |
}, []) | |
console.log("vals reduce: ", vals) | |
return vals | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment