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 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;
"ParsedData is ",
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 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 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")
const $ = cheerio.load(content);
//use $ to interact with elements
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 :
- logging specific events to the database
- 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 :)
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 = [
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.
This is the example of chalk used with the 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
Then it will run in developer mode and will log pretty helpful information regarding request like *execution time *, *response code * etc
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 🙏