Saturday, October 25, 2025
HomeLanguagesJavascriptLodash _.pipeline() Method

Lodash _.pipeline() Method

The Lodash _.pipeline() method takes a list of functions, either as an array or as arguments, and returns a function that takes some value as its argument and runs it through a pipeline of the original functions given in this function.

Syntax:

_.pipeline( func1, func2,..., funcn );

Parameters: This method accepts a single parameter in the form of n functions and hence operate upon given value.

Return Value: This method returns a function.

Note: To execute the below examples, you have to install the lodash-contrib library by using this command prompt and execute the following command.

npm install lodash-contrib

Below examples illustrate the Lodash _.pipeline() method in JavaScript:

Example 1: Passing functions as arguments.

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function cb (x) 
{ 
    return x * x * x; 
};
function tp (x) 
{ 
    return 3 * x; 
};
function db (x) 
{ 
    return 2 * x; 
};
var func = _.pipeline(cb, tp, db);
  
console.log(func(5));


Output:

750

Example 2: Passing functions as an array.

Javascript




// Defining lodash contrib variable
var _ = require('lodash-contrib'); 
  
function cb (x) 
{ 
    return x * x * x; 
};
function tp (x) 
{ 
    return 3 * x; 
};
function db (x) 
{ 
    return 2 * x; 
};
  
var func = _.pipeline([tp, cb, db]);
  
console.log(func(5));


Output:

6750
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS