Small application in NodeJS that, given a text file (from a path or from an url), prints some statistics about the text file, such as number of words, number of whitespaces and the words that are repeated more than ten times.
Ensure to have NodeJS v20 or above. If you use nvm, you can launch the following command:
nvm use
to refer to the v20.11.4 or NodeJS.
Install the dependencies first:
npm ci
The application is written in Typescript, so it is necessary to build it before:
npm run build
Then you can run the application, including the path with the --path
argument:
npm run start -- --path <path-to-the-text-file>
Path can be either a file path or an URL. The application automatically recognize what it is, and fetch the content correctly. Here's are valid examples:
npm run start -- --path ./tests/docs/lorem-ipsum.txt
# Or
npm run start -- --path https://filesamples.com/samples/document/txt/sample1.txt
Unit tests are located in the ./tests
folder and can be launched with:
npm run test
Remember to ensure that existing tests are passing in case of any modification to the code
This code follows the Airbnb style guide and uses ESLint to check the code. In case you make any modification, remember to lint the code with the following command:
npm run lint