Top Utility Packages In Javascript
Tags: webdev, beginners, codenewbie, javascript
Published: 2021-05-11 02:42:20

### 📢 TL:DR :

We all seek for utility packages on *npm*. No Matter we admire it or not, everyone (once a day or many times a day ) needs some **UTILITY**. So Here is the list of some utility packages which makes your life a bit easier.

------------------------------

### 🛠 Papa Parse :

This is the great package when we deal with files. Consider a scenario, you are building a automation system, which query's the data from third party API and process it internally and outputs processed data. 

During your development, you want to process massive amount of CSV data, then **Papa Parse ** is your  🗡Go-to Man 🗡

Here is an example 

```javascript 
          let CSVdata = await getCSVContent(getCSVContentURL);

          let parsedData = papaParse.parse(CSVdata).data;

          console.log(
            "ParsedData is  ",
            parsedData.length
          );

```

Here, after await() call, we are getting CSV file, which contains the data. Once we got the data, I used papa parse and Papa parse give me the array of objects (In my case) pretty easily without any jargon. 

There is whole lot more functionality you can <a href="https://www.papaparse.com/docs"> use</a>

--------------------------------

### 💻 Puppteer:
Puppteer is the browser automation tool. It is a pretty similar as compared to Selenium or any other automation tool. But, advantage of Puppeteer, it provides wide variety of functionality with respect to headless chromium browser and lower level DOM API's 

If you want to know more about it then, I have a article regarding usage of Puppteer take a look at it  👉👉 <a href="https://dev.to/sudarshansb143/productivity-hacks-using-puppeteer-81d">Here </a> 

--------------------------------

### ⚡ Cheerio ⚡:
Cheerio can be used with puppeteer. Cheerio parses the available html data and gives us the ability to interact with data and extract the useful information. It can act as parser, if you are building the 🔍 SEO scrapper 🔍 or the Resume scrapper for your organization 

```javascript
     const cheerio = require("cheerio")
	 
	 //jquery style
    const $ = cheerio.load(content);
	
	//use $ to interact with elements
```

--------------------------------------
###GCL :
GCL is the short form for the get-current-line. It is my favorite package. It is totally optionally to use but, if you have project where you have to implement :

1. logging specific events to the database 
2. getting the line number, where the specific code is executed

then you must use it. It does nothing but gives you the current line of code with very simplistic API 

```javascript 
          console.log("\n Getting current line number \n");
          let currentLineNumber = gcl.default().line;

```
Pretty simple :) 

-------------------------------------------------

### 🤑 Proxy Chain 🤑 :

Whenever you want to apply the proxy to your nodejs, then use it undoubtedly. Proxy chain provides us the  way to interact the proxy with pretty  simple way. It generates the new proxy URL which you can put into the configuration  and then we are good to go 

Here the example usage of proxy chain 

```javascript 
        let newProxyUrl = await proxyChain.anonymizeProxy(proxyUrl);

        launchConfigObject.args = [
          "--no-sandbox",
          "--disable-setuid-sandbox",
          `--proxy-server=${newProxyUrl}`,
        ];
        console.log("proxy executed ....");

```

This is the example of proxy chain with puppeteer. While doing automation, applying proxy is non-written rule. In the above snippet, I have used *anonymizeProxy()* API of proxy chain which builds ready to use proxy URL for us.

------------------------------------

### 🖍 Chalk  :-

If you are the fan of doing the colorful stuff in the terminal then this is for you. Chalk provides the API's which makes our terminal colorful and it is pretty  light weight and flexible to use. we can directly put it into native javascript API's like *console.log* and  use it comprehensively

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hhnoke6ebzx71g0zkhy9.png)
 
 
 This is the example of chalk used with the *morgan*.
 
 --------------------------------
 
### 🏏Morgan :
 
Morgan is used as the logger for the nodejs server it is pretty helpful to interact with the incoming requests and  all these stuff happening inside the nodejs. It gives us the prebuilt modification of request logging. if you used 
``` javascript 
		app.use(morgan("dev"))
```
Then it will run in developer mode and will log pretty helpful information regarding request like *execution time *, *response code * etc

---------------------------------------

### ☀ Final Thoughts ☀ : 

These is the list of 0.00000001 % of npm packages which are available to use. Using packages is pretty much optional and preference based. but, using them saves us from *Re implementing the Wheel *

Please, let me know in comments if you know any other utility packages

Thanks For Reading  🙏