-
-
Save DanielRakh/151215f92ba7c738eadade2cddc4854d to your computer and use it in GitHub Desktop.
This file contains 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
export default function interpolate({ | |
inputRange: [minX, maxX], | |
outputRange: [minY, maxY], | |
clamp, | |
fn = linearStep | |
}: Props): (number) => mixed { | |
const slope = (maxY - minY) / (maxX - minX); | |
function makeInterpolationFunc(x: number) { | |
const res = (x - minX) * (slope + minY); | |
return fn(minY, maxY, res, clamp); | |
} | |
return makeInterpolationFunc; | |
} |
😆
Thank you gentlemen!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pretty sure that’s a type signature. The type of the object passed to the interpolate function is props and it returns a function that accepts a single number arg and returns something of mixed type.
Types or bullshit — JS people trying to be cool