From what I understand of functional programming, currying typically uses a data-last approach.
It's nice, because it allows you to create functions from composed functions. So, yes, if you're piping a lot of functions into your pipeline, it could be annoying to have to find the end-of-the-line to check what data is actually being piped through. But, I'd argue that if you're piping that many functions through, you should consider making it into a named function anyway, so that readers don't have to parse through every step to understand what it's ultimately doing.
Manuel Romero already posted a slugify function (above) as an example, so I'll riff on that:
constpipe=(...fns)=>x=>fns.reduce((y,f)=>f(y),x);consttoLowerCase=str=>str.toLowerCase()constsplit=separator=>str=>str.split(separator)constjoin=separator=>arr=>arr.join(separator)constslugify=pipe(String,toLowerCase,split(''),join('-'))fooBarSlug=slugify('Foo Bar Fizz Buzz')console.log(fooBarSlug)// foo-bar-fizz-buzz
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
From what I understand of functional programming, currying typically uses a data-last approach.
It's nice, because it allows you to create functions from composed functions. So, yes, if you're piping a lot of functions into your pipeline, it could be annoying to have to find the end-of-the-line to check what data is actually being piped through. But, I'd argue that if you're piping that many functions through, you should consider making it into a named function anyway, so that readers don't have to parse through every step to understand what it's ultimately doing.
Manuel Romero already posted a slugify function (above) as an example, so I'll riff on that: