This project provides utility functions to manage and calculate available appointment slots in a scheduling system.
These instructions will help you set up the project on your local machine for development and testing purposes.
- Node.js and npm installed on your machine. If not, you can download and install them from here.
-
Clone the repository:
git clone https://github.com/arizakevin/dates-exercices
-
Navigate to the project directory:
cd dates-exercices
-
Install the required modules:
npm install
To run the main code, use the following command:
npm start
To run the unit tests, use the following command:
npm run test
timeToMinutes(time: string)
: Converts a time string to minutes since the start of the day.availableSlotsForDay(appointments: Appointment[])
: Calculates the available 30-minute slots for a given day based on the provided appointments.totalAvailableSlots(weekAppointments: Appointment[][])
: Calculates the total available 30-minute slots for a week based on the provided appointments.
The codebase integrates Prettier, a popular code formatter, ensuring consistent code style across the project. This helps maintain readability and reduces the chances of style-related issues.
With Husky, I've set up pre-commit hooks to ensure that every commit meets our quality standards. Before any commit is made, Husky checks for code formatting and runs tests to ensure everything is in order.
The project includes several npm scripts to streamline common tasks:
test
: Runs unit tests using Jest.start
: Compiles the TypeScript code and then runs the main application.format
: Formats the entire codebase using Prettier.prepare
: Sets up Husky hooks.check-types
: Checks TypeScript types without emitting output.check-format
: Checks if the codebase is formatted correctly using Prettier.
To run any of these scripts, use the command npm run <script-name>
. For example, to run tests, use npm run test
.