π’ 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 :
- 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 :)
π€ 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
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 π