Lodash flow method
语法
Creates a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.
参数
[funcs] (...(Function|Function[])) − The functions to invoke.
输出
(Function) − Returns the new composite function.
实例
var _ = require('lodash');
function square(n) {
return n * n;
}
var addAndSquare = _.flow([_.add, square]);
var result = addAndSquare(3, 2);
console.log(result);
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出