Spaces:
Sleeping
Sleeping
Download src/utils/seatHelper.js from Huzaifa1435/Carpool: direct link, hf CLI and curl.
- Browser
- Download file 372 Bytes
-
https://huggingface.co/spaces/Huzaifa1435/Carpool/resolve/main/src/utils/seatHelper.js
- Command line
-
hf download hf://spaces/Huzaifa1435/Carpool/src/utils/seatHelper.js
-
curl -L -o seatHelper.js https://huggingface.co/spaces/Huzaifa1435/Carpool/resolve/main/src/utils/seatHelper.js
372 Bytes
| function seatUpdateFromRide(ride, delta) { | |
| const totalSeats = ride.totalSeats ?? ride.availableSeats ?? 0; | |
| let available = ride.availableSeats ?? totalSeats; | |
| available += delta; | |
| if (available < 0) throw new Error('Ride is full'); | |
| if (available > totalSeats) available = totalSeats; | |
| return { available, totalSeats }; | |
| } | |
| module.exports = { seatUpdateFromRide }; | |