This post is about the concept of currying, from functional programming, and when you should use it in JavaScript.
I'm going to be honest. You pro...
For further actions, you may consider blocking this person and/or reporting abuse
If you add pipeline operators to build, then currying will be much easier because you much cleaner way compose functions together.
which is equal:
render(validateInputState(normalizeEventParameters(userInputEvent)));
just fare more readable.
My luck, for 2 years I can write js fn code with pipeline operator.
IMO not necessary to add to language core. It easily can be achieved with transpilers or with library like ramda using traditional syntax.
But ramada give extra weigth to program vs pipelin operator transformed to pure js function call.
even ramda gives you pure function calls. It's down to optimization. I doubt parsing pipe code through babel would give you any performance boost. But who knows i haven't tried. I have nothing against pipe syntax. If it makes it into specification I will use it.
Isn't this an experimental feature in stage 2?
Afaik tou need babel or another tool to "patch" it into a different expression for it to work.
You're right, the pipeline operator is just a Stage 2 experimental feature. The science application written in React is quite complex, and Babel is also included in the build system.
.babelrc
in VS code, also need to be set:
"javascript.validate.enable": false
Disabling all built-in syntax checking with
"javascript.validate.enable": false
seems risky.You'll need to set up a tone of rules in ESLint to validate the rest, all this just to use a single feature that needs to escalate 2 stages more before being implemented.
I'd wholeheartedly suggest avoid using the pipeline operator till it's implemented in the core API (if it does end up like that). In the meantime, you can have a function to handle that pretty easily:
It will work for both async and sync operations, though you can have a sync version of it as well, like so:
Usage example:
You can learn more about this here:
JS Functional Concepts: Pipe and Compose
JoelBonetR 🥇 ・ Jan 2 ・ 3 min read
Best regards 😃
or just ust ramda.js
Function Composition/Piping and Currying are not the same, tho
it's actually very usuful in React...
Here is an example
And later:
I use this concept a lot.
Hi SlimTim, In the last few years I have been learning more FP techniques and applying them where appropriate in my JS code. Currying is an important technique to know but I have yet to find an opportunity to employ it. However, I use the associated technique of Partial Application (AP) extensively.
This is a fine discussion of the topic of Currying and I hope you follow it up with one on PA, which I think has far more utility.
Regards, Tracy
currying is terrible, pass multiple parameters to your functions, it's literally gonna save you time, money, and your sanity. functions should not return other functions; they should return values, at least in web development.
great
Currying is not commonly needed in typical JavaScript codebases. However, where function composition is fundamental, curried functions can be more elegant than the normal practice.
Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍