Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinit Shahdeo committed Dec 7, 2019
1 parent aee18fc commit 810be77
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
Binary file modified bin/parking_lot
Binary file not shown.
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*
*
* @description packages the parking_lot inside bin/ folder for the host platform (macOS/Linux/Windows).
* It uses `pkg` npm module to package the Node.js application.
* Learn more: https://www.npmjs.com/package/pkg
*
*
*/
const sh = require('shelljs'),
fs = require('fs'),
Expand Down
4 changes: 2 additions & 2 deletions scripts/create-docs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*
* @description creates documentation for the code using JSDoc in out/ folder
*
*
*/

const sh = require('shelljs'),
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-unit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*
* @description running unit tests for different functions in ParkingLot class.
*
*
*/
const sh = require('shelljs');

Expand Down
4 changes: 2 additions & 2 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
*
*
* @description runs all the tests i.e. unit tests, lint tests and system tests.
* the test fails if any of the above test suites fail.
*
*
*/
const sh = require('shelljs'),
chalk = require('chalk'),
Expand Down
6 changes: 3 additions & 3 deletions scripts/utils/findHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
module.exports = function () {
var opsys = process.platform;

if (opsys === 'darwin') {
opsys = 'MacOS';
}
Expand All @@ -13,6 +13,6 @@ module.exports = function () {
else if (opsys === 'linux') {
opsys = 'Linux';
}

return opsys;
};
};
8 changes: 4 additions & 4 deletions src/config/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const chalk = require('chalk'); // for styling terminal strings

/**
*
*
* @description list of all the user commands supported
*/
const userCommands = [
Expand Down Expand Up @@ -51,14 +51,14 @@ const userCommands = [
}
];

console.log(chalk.bold.yellow('The following user commands are supported:\n'))
console.log(chalk.bold.yellow('The following user commands are supported:\n'));

// logging supported commands for help, triggered via `npm run help`
for (var index = 0; index <= 10; index++) {
(function (command) {
// displaying commands in interval of 2 seconds for better readability
setTimeout(function() {
setTimeout(function () {
console.log(chalk.green.bold(command.type), ':', chalk.bold.bold(command.description), '\n');
}, index*2000);
}, index * 2000);
})(userCommands[index]);
}
16 changes: 8 additions & 8 deletions src/modules/parkingLot.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ParkingLot {
throw new Error(`Slot number ${index + 1} is not found`);
}
else if (this.parkingSlots[index] === null) {
throw new Error(`Slot number ${index+1} is already free`);
throw new Error(`Slot number ${index + 1} is already free`);
}
else if (index > -1 && index <= this.parkingSlots.length) {
this.parkingSlots[index] = null;
Expand All @@ -94,7 +94,7 @@ class ParkingLot {
}

/**
*
*
* @param {String} input user's input via terminal
* @description it makes the slot free for the car of given registration number.
* It throws an error if car is not found.
Expand Down Expand Up @@ -135,9 +135,9 @@ class ParkingLot {
throw new Error('Sorry, parking lot is empty');
}
}

/**
*
*
* @param {String} input user's input via terminal
* @description returns a comma separated string of registration numbers of car having same color.
* It returns null if car is not found
Expand All @@ -156,9 +156,9 @@ class ParkingLot {
return null;
}
}

/**
*
*
* @param {String} input user's input via terminal
* @description returns a comma separated string of slot numbers for cars of given color.
* It returns null if cars of given color is not found.
Expand All @@ -177,9 +177,9 @@ class ParkingLot {
return null;
}
}

/**
*
*
* @param {String} input user's input via terminal
* @description returns slot number for given car number.
* It returns null if car is not found.
Expand Down
30 changes: 15 additions & 15 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// This file contains all the pure utility functions

/**
*
*
* @param {Array} arr the array in which the function will search for the element
* @param {Number} element element to be searched
* @param {Number} start starting index of the array
* @param {Number} end last index of the array
* @description This is an implementation of Binary search algorithm.
* We might use this for searching operation
*/
const binarySearch = function (arr, element, start, end) {
const binarySearch = function (arr, element, start, end) {
if (start > end) {
return false;
return false;
}
var mid = Math.floor((start + end)/2);
if ( arr[mid] === element) {
return true;

var mid = Math.floor((start + end) / 2);

if (arr[mid] === element) {
return true;
}
if(arr[mid] > element) {
return binarySearch(arr, element, start, mid-1);

if (arr[mid] > element) {
return binarySearch(arr, element, start, mid - 1);
}

else {
return binarySearch(arr, element, mid+1, end);
}
}
return binarySearch(arr, element, mid + 1, end);
}
};

module.exports = binarySearch;

0 comments on commit 810be77

Please sign in to comment.