Skip to content

This is how we flatten data: flatten.js

Daisho Komiyama edited this page Aug 29, 2019 · 36 revisions

One day somewhere in Canada, imagine you got a visualization task with humongous size of dataset out of nowhere, you probably have to sit tight, wish your luck then try very hard to wrap your head around it. I know it because I did it.

Speaking of my case it was disaster at least at the beginning. I've spent some time just looking at screen, counting how many properties there were within an array of objects with a few hundreds of them. After 5-minute of thinking, I started writing JavaScript. This is a bad start.

After a few hours, I ended up having a few functions. Not like the principal I always had in my mind; don't repeat yourself, what each function does was way too specific that makes almost impossible to be reused in other use-cases. They are one-time-use-only functions. I hated them, even hated myself and circumstances that forced me to produce those trash.

I walked out the office, thinking to go for a jog that night.

My head was full with programming code even during a jog. I was tracing each value many times in order to imagine clearly the flow of data in a function I built in my head. By the time I finished running, I've got a vague idea of how my function should be built. I have to rewrite everything. I was totally excited.

When I woke up, I came up with an new idea

Clone this wiki locally