Skip to content

Instantly share code, notes, and snippets.

@koss-lebedev
Last active October 11, 2019 09:40
Show Gist options
  • Save koss-lebedev/1bdcf452355f9b04faee57ad752e523b to your computer and use it in GitHub Desktop.
Save koss-lebedev/1bdcf452355f9b04faee57ad752e523b to your computer and use it in GitHub Desktop.
const clamp = (value: number, clampAt: number = 30) => {
if (value > 0) {
return value > clampAt ? clampAt : value;
} else {
return value < -clampAt ? -clampAt : value;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment