Skip to content

Commit cbe7e0c

Browse files
committed
Comply with ESM syntax.
1 parent 5a290c3 commit cbe7e0c

16 files changed

+50
-62
lines changed

Diff for: Conversions/DateDayDifference.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ const DateDayDifference = (date1, date2) => {
3838

3939
// Example : DateDayDifference('17/08/2002', '10/10/2020') => 6630
4040

41-
module.exports = DateDayDifference
41+
export { DateDayDifference }

Diff for: Conversions/DateToDay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ const DateToDay = (date) => {
6161

6262
// Example : DateToDay("18/12/2020") => Friday
6363

64-
module.exports = DateToDay
64+
export { DateToDay }

Diff for: Conversions/LowerCaseConversion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ const LowerCaseConversion = (inputString) => {
3232
return newString.join('')
3333
}
3434

35-
module.exports = LowerCaseConversion
35+
export { LowerCaseConversion }

Diff for: Conversions/RailwayTimeConversion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ const RailwayTimeConversion = (timeString) => {
3232
}
3333
}
3434

35-
module.exports = RailwayTimeConversion
35+
export { RailwayTimeConversion }

Diff for: Data-Structures/Tree/AVLTree.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -234,39 +234,39 @@ const AVLTree = (function () {
234234
/**
235235
* A Code for Testing the AVLTree
236236
*/
237-
(function test () {
238-
const newAVL = new AVLTree()
239-
const size = Math.floor(Math.random() * 1000000)
240-
let uniques = 0
241-
let i, temp, j
242-
const array = []
243-
for (i = 0; i < size; i++) {
244-
temp = Math.floor(Math.random() * Number.MAX_VALUE)
245-
if (newAVL.add(temp)) {
246-
uniques++
247-
array.push(temp)
248-
}
249-
}
250-
if (newAVL.size !== uniques) {
251-
throw new Error('elements not inserted properly')
252-
}
253-
const findTestSize = Math.floor(Math.random() * uniques)
254-
for (i = 0; i < findTestSize; i++) {
255-
j = Math.floor(Math.random() * uniques)
256-
if (!newAVL.find(array[j])) {
257-
throw new Error('inserted elements not found')
258-
}
259-
}
260-
const deleteTestSize = Math.floor(uniques * Math.random())
261-
for (i = 0; i < deleteTestSize; i++) {
262-
j = Math.floor(Math.random() * uniques)
263-
temp = array[j]
264-
if (newAVL.find(temp)) {
265-
if (!newAVL.remove(temp)) {
266-
throw new Error('delete not working properly')
267-
}
268-
}
269-
}
270-
})()
237+
// (function test () {
238+
// const newAVL = new AVLTree()
239+
// const size = Math.floor(Math.random() * 1000000)
240+
// let uniques = 0
241+
// let i, temp, j
242+
// const array = []
243+
// for (i = 0; i < size; i++) {
244+
// temp = Math.floor(Math.random() * Number.MAX_VALUE)
245+
// if (newAVL.add(temp)) {
246+
// uniques++
247+
// array.push(temp)
248+
// }
249+
// }
250+
// if (newAVL.size !== uniques) {
251+
// throw new Error('elements not inserted properly')
252+
// }
253+
// const findTestSize = Math.floor(Math.random() * uniques)
254+
// for (i = 0; i < findTestSize; i++) {
255+
// j = Math.floor(Math.random() * uniques)
256+
// if (!newAVL.find(array[j])) {
257+
// throw new Error('inserted elements not found')
258+
// }
259+
// }
260+
// const deleteTestSize = Math.floor(uniques * Math.random())
261+
// for (i = 0; i < deleteTestSize; i++) {
262+
// j = Math.floor(Math.random() * uniques)
263+
// temp = array[j]
264+
// if (newAVL.find(temp)) {
265+
// if (!newAVL.remove(temp)) {
266+
// throw new Error('delete not working properly')
267+
// }
268+
// }
269+
// }
270+
// })()
271271

272-
module.exports = AVLTree
272+
export { AVLTree }

Diff for: Hashes/SHA1.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,5 @@ function SHA1 (message) {
170170
return HH
171171
}
172172

173-
console.log(SHA1('A Test'))
174-
console.log(SHA1('A Test'))
175-
176173
// export SHA1 function
177-
module.exports = SHA1
174+
export { SHA1 }

Diff for: Hashes/SHA256.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,4 @@ function SHA256 (message) {
185185
}
186186

187187
// export SHA256 function
188-
module.exports = SHA256
188+
export { SHA256 }

Diff for: Maths/CheckKishnamurthyNumber.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ const CheckKishnamurthyNumber = (number) => {
4141
return sumOfAllDigitFactorial === number
4242
}
4343

44-
module.exports = CheckKishnamurthyNumber
44+
export { CheckKishnamurthyNumber }

Diff for: Maths/CoPrimeCheck.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ const CoPrimeCheck = (firstNumber, secondNumber) => {
3737
return GetEuclidGCD(firstNumber, secondNumber) === 1
3838
}
3939

40-
module.exports = CoPrimeCheck
40+
export { CoPrimeCheck }

Diff for: Maths/GetEuclidGCD.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ const GetEuclidGCD = (arg1, arg2) => {
2929
return (less)
3030
}
3131

32-
module.exports = GetEuclidGCD
32+
export { GetEuclidGCD }

Diff for: Maths/ReverseNumber.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ const ReverseNumber = (number) => {
2626
return reverseNumber
2727
}
2828

29-
module.exports = ReverseNumber
29+
export { ReverseNumber }

Diff for: Maths/test/BinaryExponentiationRecursive.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { binaryExponentiation } = require('../BinaryExponentiationRecursive')
1+
import { binaryExponentiation } from '../BinaryExponentiationRecursive'
22

33
describe('BinaryExponentiationRecursive', () => {
44
it('should calculate 2 to the power of 10 correctly', () => {

Diff for: Project-Euler/Problem1.js renamed to Project-Euler/Problem001.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Find the sum of all the multiples of 3 or 5 below the provided parameter value number.
55
*/
66

7-
const readline = require('readline')
8-
97
const multiplesThreeAndFive = (num) => {
108
let total = 0
119
// total for calculating the sum
@@ -17,11 +15,4 @@ const multiplesThreeAndFive = (num) => {
1715
return total
1816
}
1917

20-
const rl = readline.createInterface({
21-
input: process.stdin,
22-
output: process.stdout
23-
})
24-
rl.question('Enter a number: ', function (num) {
25-
console.log(multiplesThreeAndFive(num)) // multiples3_5 function to calculate the sum of multiples of 3 and 5 within num
26-
rl.close()
27-
})
18+
export { multiplesThreeAndFive }

Diff for: String/AlternativeStringArrange.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ const AlternativeStringArrange = (str1, str2) => {
4141
return outStr
4242
}
4343

44-
module.exports = AlternativeStringArrange
44+
export { AlternativeStringArrange }

Diff for: String/CheckKebabCase.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ const CheckKebabCase = (varName) => {
1717
return pat.test(varName) && !varName.includes('_')
1818
}
1919

20-
module.exports = CheckKebabCase
20+
export { CheckKebabCase }

Diff for: String/CheckPascalCase.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ const CheckPascalCase = (VarName) => {
1717
return pat.test(VarName)
1818
}
1919

20-
module.exports = CheckPascalCase
20+
export { CheckPascalCase }

0 commit comments

Comments
 (0)