Last active
August 12, 2017 06:23
-
-
Save balintsera/7b1b71ab54020ebfa047bfd6397de6fe to your computer and use it in GitHub Desktop.
Functional interpolation
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
const cols = [{ ts: 1 }, { ts: 5 }, { ts: 6 }] | |
const smallest = 1 | |
const interpolatedCols = cols.reduce((accumulated, current) => { | |
const prev = accumulated[accumulated.length - 1] | |
for (let i = prev.ts + smallest; i <= current.ts; i += smallest) { | |
const element = { ts: i } | |
accumulated.push(element) | |
} | |
return accumulated | |
}, [cols[0]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment