From df4a783b06d34a0cc939e1d892964b046bf812f4 Mon Sep 17 00:00:00 2001 From: Eric Lavault <39483232+lvlte@users.noreply.github.com> Date: Mon, 11 Oct 2021 15:49:24 +0200 Subject: [PATCH] Complying with JavaScript Standard Style (npx standard --fix). --- Backtracking/GeneratePermutations.js | 2 +- .../tests/GeneratePermutations.test.js | 12 +++++------ Backtracking/tests/KnightTour.test.js | 21 +++++++++---------- Bit-Manipulation/test/IsPowerOfTwo.test.js | 2 +- Ciphers/VigenereCipher.js | 1 - Ciphers/XORCipher.js | 1 - Conversions/HexToDecimal.js | 1 - Conversions/HexToRGB.js | 1 - Conversions/TemperatureConversion.js | 5 ++--- .../Heap/test/MinPriorityQueue.test.js | 4 ++-- Data-Structures/Stack/Stack.js | 1 - Data-Structures/Tree/AVLTree.js | 2 +- Data-Structures/Tree/Trie.js | 2 +- Dynamic-Programming/MinimumCostPath.js | 1 - Dynamic-Programming/ZeroOneKnapsack.js | 2 +- Graphs/Density.js | 1 - Graphs/FloydWarshall.js | 1 - Project-Euler/Problem4.js | 2 -- Search/BinarySearch.js | 2 +- Search/ExponentialSearch.js | 2 +- Search/LinearSearch.js | 3 +-- Sorts/GnomeSort.js | 1 - 22 files changed, 28 insertions(+), 42 deletions(-) diff --git a/Backtracking/GeneratePermutations.js b/Backtracking/GeneratePermutations.js index a14388bed..1629e2aa8 100644 --- a/Backtracking/GeneratePermutations.js +++ b/Backtracking/GeneratePermutations.js @@ -18,7 +18,7 @@ const swap = (arr, i, j) => { } const permutations = arr => { - let P = [] + const P = [] const permute = (arr, low, high) => { if (low === high) { P.push([...arr]) diff --git a/Backtracking/tests/GeneratePermutations.test.js b/Backtracking/tests/GeneratePermutations.test.js index 7c8f1c540..718bf2670 100644 --- a/Backtracking/tests/GeneratePermutations.test.js +++ b/Backtracking/tests/GeneratePermutations.test.js @@ -3,12 +3,12 @@ import { permutations } from '../GeneratePermutations' describe('Permutations', () => { it('Permutations of [1, 2, 3]', () => { expect(permutations([1, 2, 3])).toEqual([ - [ 1, 2, 3 ], - [ 1, 3, 2 ], - [ 2, 1, 3 ], - [ 2, 3, 1 ], - [ 3, 1, 2 ], - [ 3, 2, 1 ] + [1, 2, 3], + [1, 3, 2], + [2, 1, 3], + [2, 3, 1], + [3, 1, 2], + [3, 2, 1] ]) }) }) diff --git a/Backtracking/tests/KnightTour.test.js b/Backtracking/tests/KnightTour.test.js index 3e7bde565..a3af01a09 100644 --- a/Backtracking/tests/KnightTour.test.js +++ b/Backtracking/tests/KnightTour.test.js @@ -4,21 +4,20 @@ describe('OpenKnightTour', () => { it('OpenKnightTour(5)', () => { const KT = new OpenKnightTour(5) expect(KT.board).toEqual([ - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 0 ] + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 0, 0] ]) KT.solve() expect(KT.board).toEqual([ - [ 19, 4, 15, 10, 25 ], - [ 14, 9, 18, 5, 16 ], - [ 1, 20, 3, 24, 11 ], - [ 8, 13, 22, 17, 6 ], - [ 21, 2, 7, 12, 23 ] + [19, 4, 15, 10, 25], + [14, 9, 18, 5, 16], + [1, 20, 3, 24, 11], + [8, 13, 22, 17, 6], + [21, 2, 7, 12, 23] ]) }) - }) diff --git a/Bit-Manipulation/test/IsPowerOfTwo.test.js b/Bit-Manipulation/test/IsPowerOfTwo.test.js index 2ad0f3742..30539f5e5 100644 --- a/Bit-Manipulation/test/IsPowerOfTwo.test.js +++ b/Bit-Manipulation/test/IsPowerOfTwo.test.js @@ -1,4 +1,4 @@ -import {IsPowerOfTwo} from '../IsPowerOfTwo' +import { IsPowerOfTwo } from '../IsPowerOfTwo' test('Check if 0 is a power of 2 or not:', () => { const res = IsPowerOfTwo(0) diff --git a/Ciphers/VigenereCipher.js b/Ciphers/VigenereCipher.js index 800c3fdd9..74d7358a9 100644 --- a/Ciphers/VigenereCipher.js +++ b/Ciphers/VigenereCipher.js @@ -73,7 +73,6 @@ function decrypt (message, key) { export { encrypt, decrypt } - // > encrypt('Hello World!', 'code') // 'Jsopq Zstzg!' diff --git a/Ciphers/XORCipher.js b/Ciphers/XORCipher.js index 2ee8205fb..944081b99 100644 --- a/Ciphers/XORCipher.js +++ b/Ciphers/XORCipher.js @@ -22,7 +22,6 @@ function XOR (str, key) { export { XOR } - // Nb: Node REPL might not output the null char '\x00' (charcode 0) // > XOR('test string', 32) diff --git a/Conversions/HexToDecimal.js b/Conversions/HexToDecimal.js index ae531c882..76d7a54cf 100644 --- a/Conversions/HexToDecimal.js +++ b/Conversions/HexToDecimal.js @@ -24,7 +24,6 @@ function hexToDecimal (hexNum) { export { hexToInt, hexToDecimal } - // > hexToDecimal('5DE9A')) // 384666 diff --git a/Conversions/HexToRGB.js b/Conversions/HexToRGB.js index 5200044b0..e726b5308 100644 --- a/Conversions/HexToRGB.js +++ b/Conversions/HexToRGB.js @@ -13,6 +13,5 @@ function hexStringToRGB (hexString) { export { hexStringToRGB } - // > hexStringToRGB('ffffff') // { r: 255, g: 255, b: 255 } diff --git a/Conversions/TemperatureConversion.js b/Conversions/TemperatureConversion.js index 75a7d69aa..8bf9130b1 100644 --- a/Conversions/TemperatureConversion.js +++ b/Conversions/TemperatureConversion.js @@ -40,8 +40,7 @@ const fahrenheitToRankine = (fahrenheit) => { const kelvinToCelsius = (kelvin) => { // Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin // Wikipedia reference: https://en.wikipedia.org/wiki/Celsius - return Math.round((kelvin) - 273.15) - + return Math.round((kelvin) - 273.15) } const kelvinToFahrenheit = (kelvin) => { @@ -53,7 +52,7 @@ const kelvinToFahrenheit = (kelvin) => { const kelvinToRankine = (kelvin) => { // Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin // Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale - return Math.round(( (kelvin) * 9 / 5)) + return Math.round(((kelvin) * 9 / 5)) } const rankineToCelsius = (rankine) => { diff --git a/Data-Structures/Heap/test/MinPriorityQueue.test.js b/Data-Structures/Heap/test/MinPriorityQueue.test.js index 320ad6783..b91e70786 100644 --- a/Data-Structures/Heap/test/MinPriorityQueue.test.js +++ b/Data-Structures/Heap/test/MinPriorityQueue.test.js @@ -4,7 +4,7 @@ describe('MinPriorityQueue', () => { const values = [5, 2, 4, 1, 7, 6, 3, 8] const capacity = values.length - const Queue = new MinPriorityQueue(capacity); + const Queue = new MinPriorityQueue(capacity) values.forEach(v => Queue.insert(v)) @@ -12,7 +12,7 @@ describe('MinPriorityQueue', () => { const mockFn = jest.fn() Queue.print(mockFn) - expect(mockFn.mock.calls.length).toBe(1) // Expect one call + expect(mockFn.mock.calls.length).toBe(1) // Expect one call expect(mockFn.mock.calls[0].length).toBe(1) // Expect one argument const heap = mockFn.mock.calls[0][0] diff --git a/Data-Structures/Stack/Stack.js b/Data-Structures/Stack/Stack.js index 59f1a31fe..93cf761be 100644 --- a/Data-Structures/Stack/Stack.js +++ b/Data-Structures/Stack/Stack.js @@ -54,5 +54,4 @@ const Stack = (function () { return Stack }()) - export { Stack } diff --git a/Data-Structures/Tree/AVLTree.js b/Data-Structures/Tree/AVLTree.js index e7f95f71c..45f1e682d 100644 --- a/Data-Structures/Tree/AVLTree.js +++ b/Data-Structures/Tree/AVLTree.js @@ -229,7 +229,7 @@ const AVLTree = (function () { return true } return _avl -}()); +}()) /** * A Code for Testing the AVLTree diff --git a/Data-Structures/Tree/Trie.js b/Data-Structures/Tree/Trie.js index c88e9ec22..a1d34d063 100644 --- a/Data-Structures/Tree/Trie.js +++ b/Data-Structures/Tree/Trie.js @@ -116,6 +116,6 @@ Trie.prototype.findOccurences = function (word) { // No such word exists if (node === null) return 0 return node.count -}; +} export { Trie } diff --git a/Dynamic-Programming/MinimumCostPath.js b/Dynamic-Programming/MinimumCostPath.js index 1c70c8cae..53765eab4 100644 --- a/Dynamic-Programming/MinimumCostPath.js +++ b/Dynamic-Programming/MinimumCostPath.js @@ -41,4 +41,3 @@ export { minCostPath } // [2, 1, 3], // [3, 2, 1] // ]) - diff --git a/Dynamic-Programming/ZeroOneKnapsack.js b/Dynamic-Programming/ZeroOneKnapsack.js index 4ced2d63f..4a9bbfa11 100644 --- a/Dynamic-Programming/ZeroOneKnapsack.js +++ b/Dynamic-Programming/ZeroOneKnapsack.js @@ -40,7 +40,7 @@ const example = () => { input.shift() const length = input.length - let output = [] + const output = [] let i = 0 while (i < length) { diff --git a/Graphs/Density.js b/Graphs/Density.js index 04a73c0a8..6659287c7 100644 --- a/Graphs/Density.js +++ b/Graphs/Density.js @@ -9,4 +9,3 @@ function density (numberOfNodes, numberOfEdges, isDirected = false) { } export { density } - diff --git a/Graphs/FloydWarshall.js b/Graphs/FloydWarshall.js index 648d5d8d4..4552d4c60 100644 --- a/Graphs/FloydWarshall.js +++ b/Graphs/FloydWarshall.js @@ -45,4 +45,3 @@ export { FloydWarshall } // [Infinity, Infinity, 1, 0] // ] // ) - diff --git a/Project-Euler/Problem4.js b/Project-Euler/Problem4.js index d6ba7a722..34fa87471 100644 --- a/Project-Euler/Problem4.js +++ b/Project-Euler/Problem4.js @@ -42,5 +42,3 @@ export const largestPalindromic = (digits) => { } return NaN // returning not a number, if any such case arise } - - diff --git a/Search/BinarySearch.js b/Search/BinarySearch.js index ce6571d55..c822cfac6 100644 --- a/Search/BinarySearch.js +++ b/Search/BinarySearch.js @@ -49,7 +49,7 @@ function binarySearchIterative (arr, x, low = 0, high = arr.length - 1) { return -1 } -export { binarySearchIterative, binarySearchRecursive} +export { binarySearchIterative, binarySearchRecursive } /* ---------------------------------- Test ---------------------------------- */ diff --git a/Search/ExponentialSearch.js b/Search/ExponentialSearch.js index 174671e70..7b023a606 100644 --- a/Search/ExponentialSearch.js +++ b/Search/ExponentialSearch.js @@ -47,7 +47,7 @@ function exponentialSearch (arr, length, value) { return binarySearch(arr, value, i / 2, Math.min(i, length)) } -export { binarySearch, exponentialSearch} +export { binarySearch, exponentialSearch } // const arr = [2, 3, 4, 10, 40, 65, 78, 100] // const value = 78 diff --git a/Search/LinearSearch.js b/Search/LinearSearch.js index a02ac3cd1..64a0e269b 100644 --- a/Search/LinearSearch.js +++ b/Search/LinearSearch.js @@ -8,8 +8,7 @@ function SearchArray (searchNum, ar, output = v => console.log(v)) { const position = Search(ar, searchNum) if (position !== -1) { output('The element was found at ' + (position + 1)) - } - else { + } else { output('The element not found') } } diff --git a/Sorts/GnomeSort.js b/Sorts/GnomeSort.js index 86f7219f1..59f68b33c 100644 --- a/Sorts/GnomeSort.js +++ b/Sorts/GnomeSort.js @@ -25,4 +25,3 @@ export function gnomeSort (items) { // const ar = [5, 6, 7, 8, 1, 2, 12, 14] // gnomeSort(ar) -