

They will have a single input and output.To make things clearer I want to define a few goals for our composed functions. Normally when you compose functions you may do it like this (without knowing you are composing):Ĭonst getMyResult = compose( myFunction, myOtherFunction, ) const myResult = getMyResult(myData) Function Composition: Invoke functions that have been listed, in order, passing the result of each function to the next in the list, and then return the final function result as the result of the whole. It avoids mutating (changing) data, and attempts to treat applications as a linear flow that pieces functions together to create a whole.
#Download lodash how to#
In this post we’ll look at how to use Lodash/fp to compose both our own functions, and the Lodash functions that you may already be using today!īefore we start coding - lets be sure that we know what we’re talking about! Functional Programming: A method of programming that focuses on using functions as first class variables. Thankfully the most popular NPM package (with 48 million downloads this month) has a very useful functional programming package to help us get started! It’s a really powerful way to program, but can be overwhelming to get started with. Have you been reading JavaScript posts lately? Maybe you’ve noticed that functional programming is really popular right now.
