Skip to content

Commit df4a783

Browse files
committed
Complying with JavaScript Standard Style (npx standard --fix).
1 parent 87a3da7 commit df4a783

22 files changed

+28
-42
lines changed

Backtracking/GeneratePermutations.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const swap = (arr, i, j) => {
1818
}
1919

2020
const permutations = arr => {
21-
let P = []
21+
const P = []
2222
const permute = (arr, low, high) => {
2323
if (low === high) {
2424
P.push([...arr])

Backtracking/tests/GeneratePermutations.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { permutations } from '../GeneratePermutations'
33
describe('Permutations', () => {
44
it('Permutations of [1, 2, 3]', () => {
55
expect(permutations([1, 2, 3])).toEqual([
6-
[ 1, 2, 3 ],
7-
[ 1, 3, 2 ],
8-
[ 2, 1, 3 ],
9-
[ 2, 3, 1 ],
10-
[ 3, 1, 2 ],
11-
[ 3, 2, 1 ]
6+
[1, 2, 3],
7+
[1, 3, 2],
8+
[2, 1, 3],
9+
[2, 3, 1],
10+
[3, 1, 2],
11+
[3, 2, 1]
1212
])
1313
})
1414
})

Backtracking/tests/KnightTour.test.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ describe('OpenKnightTour', () => {
44
it('OpenKnightTour(5)', () => {
55
const KT = new OpenKnightTour(5)
66
expect(KT.board).toEqual([
7-
[ 0, 0, 0, 0, 0 ],
8-
[ 0, 0, 0, 0, 0 ],
9-
[ 0, 0, 0, 0, 0 ],
10-
[ 0, 0, 0, 0, 0 ],
11-
[ 0, 0, 0, 0, 0 ]
7+
[0, 0, 0, 0, 0],
8+
[0, 0, 0, 0, 0],
9+
[0, 0, 0, 0, 0],
10+
[0, 0, 0, 0, 0],
11+
[0, 0, 0, 0, 0]
1212
])
1313

1414
KT.solve()
1515
expect(KT.board).toEqual([
16-
[ 19, 4, 15, 10, 25 ],
17-
[ 14, 9, 18, 5, 16 ],
18-
[ 1, 20, 3, 24, 11 ],
19-
[ 8, 13, 22, 17, 6 ],
20-
[ 21, 2, 7, 12, 23 ]
16+
[19, 4, 15, 10, 25],
17+
[14, 9, 18, 5, 16],
18+
[1, 20, 3, 24, 11],
19+
[8, 13, 22, 17, 6],
20+
[21, 2, 7, 12, 23]
2121
])
2222
})
23-
2423
})

Bit-Manipulation/test/IsPowerOfTwo.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {IsPowerOfTwo} from '../IsPowerOfTwo'
1+
import { IsPowerOfTwo } from '../IsPowerOfTwo'
22

33
test('Check if 0 is a power of 2 or not:', () => {
44
const res = IsPowerOfTwo(0)

Ciphers/VigenereCipher.js

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ function decrypt (message, key) {
7373

7474
export { encrypt, decrypt }
7575

76-
7776
// > encrypt('Hello World!', 'code')
7877
// 'Jsopq Zstzg!'
7978

Ciphers/XORCipher.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ function XOR (str, key) {
2222

2323
export { XOR }
2424

25-
2625
// Nb: Node REPL might not output the null char '\x00' (charcode 0)
2726

2827
// > XOR('test string', 32)

Conversions/HexToDecimal.js

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function hexToDecimal (hexNum) {
2424

2525
export { hexToInt, hexToDecimal }
2626

27-
2827
// > hexToDecimal('5DE9A'))
2928
// 384666
3029

Conversions/HexToRGB.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ function hexStringToRGB (hexString) {
1313

1414
export { hexStringToRGB }
1515

16-
1716
// > hexStringToRGB('ffffff')
1817
// { r: 255, g: 255, b: 255 }

Conversions/TemperatureConversion.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ const fahrenheitToRankine = (fahrenheit) => {
4040
const kelvinToCelsius = (kelvin) => {
4141
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
4242
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
43-
return Math.round((kelvin) - 273.15)
44-
43+
return Math.round((kelvin) - 273.15)
4544
}
4645

4746
const kelvinToFahrenheit = (kelvin) => {
@@ -53,7 +52,7 @@ const kelvinToFahrenheit = (kelvin) => {
5352
const kelvinToRankine = (kelvin) => {
5453
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
5554
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
56-
return Math.round(( (kelvin) * 9 / 5))
55+
return Math.round(((kelvin) * 9 / 5))
5756
}
5857

5958
const rankineToCelsius = (rankine) => {

Data-Structures/Heap/test/MinPriorityQueue.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ describe('MinPriorityQueue', () => {
44
const values = [5, 2, 4, 1, 7, 6, 3, 8]
55
const capacity = values.length
66

7-
const Queue = new MinPriorityQueue(capacity);
7+
const Queue = new MinPriorityQueue(capacity)
88

99
values.forEach(v => Queue.insert(v))
1010

1111
it('Check heap ordering', () => {
1212
const mockFn = jest.fn()
1313
Queue.print(mockFn)
1414

15-
expect(mockFn.mock.calls.length).toBe(1) // Expect one call
15+
expect(mockFn.mock.calls.length).toBe(1) // Expect one call
1616
expect(mockFn.mock.calls[0].length).toBe(1) // Expect one argument
1717

1818
const heap = mockFn.mock.calls[0][0]

Data-Structures/Stack/Stack.js

-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ const Stack = (function () {
5454
return Stack
5555
}())
5656

57-
5857
export { Stack }

Data-Structures/Tree/AVLTree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const AVLTree = (function () {
229229
return true
230230
}
231231
return _avl
232-
}());
232+
}())
233233

234234
/**
235235
* A Code for Testing the AVLTree

Data-Structures/Tree/Trie.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@ Trie.prototype.findOccurences = function (word) {
116116
// No such word exists
117117
if (node === null) return 0
118118
return node.count
119-
};
119+
}
120120

121121
export { Trie }

Dynamic-Programming/MinimumCostPath.js

-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ export { minCostPath }
4141
// [2, 1, 3],
4242
// [3, 2, 1]
4343
// ])
44-

Dynamic-Programming/ZeroOneKnapsack.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const example = () => {
4040
input.shift()
4141
const length = input.length
4242

43-
let output = []
43+
const output = []
4444

4545
let i = 0
4646
while (i < length) {

Graphs/Density.js

-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ function density (numberOfNodes, numberOfEdges, isDirected = false) {
99
}
1010

1111
export { density }
12-

Graphs/FloydWarshall.js

-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ export { FloydWarshall }
4545
// [Infinity, Infinity, 1, 0]
4646
// ]
4747
// )
48-

Project-Euler/Problem4.js

-2
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,3 @@ export const largestPalindromic = (digits) => {
4242
}
4343
return NaN // returning not a number, if any such case arise
4444
}
45-
46-

Search/BinarySearch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function binarySearchIterative (arr, x, low = 0, high = arr.length - 1) {
4949
return -1
5050
}
5151

52-
export { binarySearchIterative, binarySearchRecursive}
52+
export { binarySearchIterative, binarySearchRecursive }
5353

5454
/* ---------------------------------- Test ---------------------------------- */
5555

Search/ExponentialSearch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function exponentialSearch (arr, length, value) {
4747
return binarySearch(arr, value, i / 2, Math.min(i, length))
4848
}
4949

50-
export { binarySearch, exponentialSearch}
50+
export { binarySearch, exponentialSearch }
5151

5252
// const arr = [2, 3, 4, 10, 40, 65, 78, 100]
5353
// const value = 78

Search/LinearSearch.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ function SearchArray (searchNum, ar, output = v => console.log(v)) {
88
const position = Search(ar, searchNum)
99
if (position !== -1) {
1010
output('The element was found at ' + (position + 1))
11-
}
12-
else {
11+
} else {
1312
output('The element not found')
1413
}
1514
}

Sorts/GnomeSort.js

-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ export function gnomeSort (items) {
2525

2626
// const ar = [5, 6, 7, 8, 1, 2, 12, 14]
2727
// gnomeSort(ar)
28-

0 commit comments

Comments
 (0)