Lodash - flowRight method


Advertisements

Syntax

_.flowRight([funcs])

This method is like _.flow except that it creates a function that invokes the given functions from right to left.

Arguments

  • [funcs] (...(Function|Function[])) − The functions to invoke.

Output

  • (Function) − Returns the new composite function.

Example

var _ = require('lodash');

function square(n) {
   return n * n;
}

var addAndSquare = _.flowRight([square, _.add]);
var result = addAndSquare(3, 2);
console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

25
lodash_util.htm
Advertisements