This project consists of building a program simulating wc command.
Thanks🙏 to John Crickett ! It's one of his coding challenges helping software engineers to improve their skills.
You can find more about the challenges here👉 https://codingchallenges.fyi/challenges/challenge-wc/
- Typescript : programming language
- jest: for testing
- c : number of bytes
- l : number of lines
- m : number of characters
- w: number of words
- Go to the root of the repo and type
npm run buildto build - Type
chmod +x ccwc.shto give execution access to ccwc (codingchallenges wc is a simple script I created to easily run the program, feel free tocat ccwc.sh) - Bingo ! now we're ready to enjoy our own wc like so :
./ccwc.sh -option infile Or ./ccwc.sh infile -option - No infile ? Ok, you can pipe (our wc will take input from stdin).
- Example :
./ccwc.sh -l data/text.txt // output : 7145 data/text.txtPS: Groupping options, comming soon.
Through this project, I practiced reading file content as stream with nodejs (https://nodejs.org/api/stream.html) which is very important while processing a big files.
Another alternative for processing files in to use fs.readFile(path, mode) slower because it reads all content at once, more suitable for small files.
Any feedback ? Yes, please🙂