sindresorhus / math-clamp

Clamp a number
MIT License
14 stars 3 forks source link

Order of arguments #1

Closed emilbayes closed 9 years ago

emilbayes commented 9 years ago

How come you chose the value to be clamped as the first argument? It makes it hard to curry the function for easy reuse.

sindresorhus commented 9 years ago

I don't make APIs based on how easy they can be curried. I prefer to keep the main input as the first argument. This is how most JS APIs are designed. If you curry a lot, you can use the Lodash _.rearg method. I do wish we had a native method like bind that could bind in the reverse order or the last parameter though. Would make currying a lot more feasible.