Every `curry` implementation I’ve met is broken in some way.

Let’s think what `curry` function should do. First: is should implement valid currying. Second: it should keep function name untouched. Third: it should keep function length. Fourth: it should allow to bind `this` after any number of arguments (until last).

Missed name? Expect bugs. Missed length. Expect bugs. Etc.

Not a rocket science, right? Then why every existing curry implementation is broken?

let sum3 = curry((x, y, z) => {
if (this) {
return [x + y + z, this];
} else {
return x + y + z;
// Cannot assign to read only property ‘name’ of function


— — — — — — — — — — — — — — — — — — —


Go, check it out yourself.

Software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ivan Kleshnin

Ivan Kleshnin

Software engineer

More from Medium

Refactoring/Getting Out Those Stubborn Code Smells

🏋️ The Might of Microtypes

Untaught foundations for software development

Understanding Maybe and Either in Functional Programming