Top Utility Packages In Javascript

? 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.

? …


This content originally appeared on DEV Community and was authored by Sudarshan Sawandkar

? 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

          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 use

? 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 ?? Here

⚡ 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

     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

          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

        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

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

        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 ?


This content originally appeared on DEV Community and was authored by Sudarshan Sawandkar


Print Share Comment Cite Upload Translate Updates
APA

Sudarshan Sawandkar | Sciencx (2021-05-11T02:42:20+00:00) Top Utility Packages In Javascript. Retrieved from https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/

MLA
" » Top Utility Packages In Javascript." Sudarshan Sawandkar | Sciencx - Tuesday May 11, 2021, https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/
HARVARD
Sudarshan Sawandkar | Sciencx Tuesday May 11, 2021 » Top Utility Packages In Javascript., viewed ,<https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/>
VANCOUVER
Sudarshan Sawandkar | Sciencx - » Top Utility Packages In Javascript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/
CHICAGO
" » Top Utility Packages In Javascript." Sudarshan Sawandkar | Sciencx - Accessed . https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/
IEEE
" » Top Utility Packages In Javascript." Sudarshan Sawandkar | Sciencx [Online]. Available: https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/. [Accessed: ]
rf:citation
» Top Utility Packages In Javascript | Sudarshan Sawandkar | Sciencx | https://www.scien.cx/2021/05/11/top-utility-packages-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.