hello everyone my name is Taj and this video is my submission for web 322 assignment 1 in this assignment I have created a nodejs application that processes file and directories to generate detail reports I'll explain my code step by step demonstrate how it works and share what I have learned while building it now we'll start with the code over you my I have used Three core modules for this assignment that is read line fs and path now starting with my first function that is reading the pro processing the file the process file function reads the
content of a file analyses it and generates a report here is how my code works it calculates the full path of a file using path do join and the file using fs. read file so here with the full with the object full path it will it will get the full path of the file and the next next line of code will with that code we will get the full content of the file and our computer would be our compiler would be able to access the file content of the file then I'll C the I clean
up the cont content content by replacing Extra Spaces and removing punctuation using regular Expressions so we'll generate a report according to that we'll skip the spaces and other punctu punctation marks the program will calculate the number of characters words and the longest word and will find the most repeated word so at the end of at the end of the compilation we'll get the report for the file which will include the file name number of characters which will include including the spaces number of words longest word and the most repeated words now moving on to my
next function that is to process a directory I implemented process directory function here this function list all files in a directory in a reverse alphabetical order along with their sizes so with using fs. Rd it will use the it will fetch the list of the files it will filter only the file using then we can filter the file using FS do EST sync and short them in Reverse alphabetical order with do short so this this part of code what we are doing with this is we are getting the list of the file we'll filter the
file user using fs. sync and then we'll short it with the do short now moving on to the main function of my code finally the main function ties everything together it prompts the user to choose between a between processing a file or a directory calls the appropriate function and handles the invalid input Grace f so now we'll try running our code so for now we'll start with processing a file so we have four files in our assignment we'll start with any random file that is gu surfing for now so here is the report of the
file the file name number of characters number of words longest word repeated word now we'll try moving with the directory we'll try Mo reading our current directory so we C the all files in a reverse alphabetical order with the their sizes so that's all for my assignment thank you