Comply with ESM syntax.

This commit is contained in:
Eric Lavault
2021-10-09 13:18:40 +02:00
parent 5a290c3ae5
commit cbe7e0c89f
16 changed files with 50 additions and 62 deletions

View File

@ -38,4 +38,4 @@ const DateDayDifference = (date1, date2) => {
// Example : DateDayDifference('17/08/2002', '10/10/2020') => 6630 // Example : DateDayDifference('17/08/2002', '10/10/2020') => 6630
module.exports = DateDayDifference export { DateDayDifference }

View File

@ -61,4 +61,4 @@ const DateToDay = (date) => {
// Example : DateToDay("18/12/2020") => Friday // Example : DateToDay("18/12/2020") => Friday
module.exports = DateToDay export { DateToDay }

View File

@ -32,4 +32,4 @@ const LowerCaseConversion = (inputString) => {
return newString.join('') return newString.join('')
} }
module.exports = LowerCaseConversion export { LowerCaseConversion }

View File

@ -32,4 +32,4 @@ const RailwayTimeConversion = (timeString) => {
} }
} }
module.exports = RailwayTimeConversion export { RailwayTimeConversion }

View File

@ -234,39 +234,39 @@ const AVLTree = (function () {
/** /**
* A Code for Testing the AVLTree * A Code for Testing the AVLTree
*/ */
(function test () { // (function test () {
const newAVL = new AVLTree() // const newAVL = new AVLTree()
const size = Math.floor(Math.random() * 1000000) // const size = Math.floor(Math.random() * 1000000)
let uniques = 0 // let uniques = 0
let i, temp, j // let i, temp, j
const array = [] // const array = []
for (i = 0; i < size; i++) { // for (i = 0; i < size; i++) {
temp = Math.floor(Math.random() * Number.MAX_VALUE) // temp = Math.floor(Math.random() * Number.MAX_VALUE)
if (newAVL.add(temp)) { // if (newAVL.add(temp)) {
uniques++ // uniques++
array.push(temp) // array.push(temp)
} // }
} // }
if (newAVL.size !== uniques) { // if (newAVL.size !== uniques) {
throw new Error('elements not inserted properly') // throw new Error('elements not inserted properly')
} // }
const findTestSize = Math.floor(Math.random() * uniques) // const findTestSize = Math.floor(Math.random() * uniques)
for (i = 0; i < findTestSize; i++) { // for (i = 0; i < findTestSize; i++) {
j = Math.floor(Math.random() * uniques) // j = Math.floor(Math.random() * uniques)
if (!newAVL.find(array[j])) { // if (!newAVL.find(array[j])) {
throw new Error('inserted elements not found') // throw new Error('inserted elements not found')
} // }
} // }
const deleteTestSize = Math.floor(uniques * Math.random()) // const deleteTestSize = Math.floor(uniques * Math.random())
for (i = 0; i < deleteTestSize; i++) { // for (i = 0; i < deleteTestSize; i++) {
j = Math.floor(Math.random() * uniques) // j = Math.floor(Math.random() * uniques)
temp = array[j] // temp = array[j]
if (newAVL.find(temp)) { // if (newAVL.find(temp)) {
if (!newAVL.remove(temp)) { // if (!newAVL.remove(temp)) {
throw new Error('delete not working properly') // throw new Error('delete not working properly')
} // }
} // }
} // }
})() // })()
module.exports = AVLTree export { AVLTree }

View File

@ -170,8 +170,5 @@ function SHA1 (message) {
return HH return HH
} }
console.log(SHA1('A Test'))
console.log(SHA1('A Test'))
// export SHA1 function // export SHA1 function
module.exports = SHA1 export { SHA1 }

View File

@ -185,4 +185,4 @@ function SHA256 (message) {
} }
// export SHA256 function // export SHA256 function
module.exports = SHA256 export { SHA256 }

View File

@ -41,4 +41,4 @@ const CheckKishnamurthyNumber = (number) => {
return sumOfAllDigitFactorial === number return sumOfAllDigitFactorial === number
} }
module.exports = CheckKishnamurthyNumber export { CheckKishnamurthyNumber }

View File

@ -37,4 +37,4 @@ const CoPrimeCheck = (firstNumber, secondNumber) => {
return GetEuclidGCD(firstNumber, secondNumber) === 1 return GetEuclidGCD(firstNumber, secondNumber) === 1
} }
module.exports = CoPrimeCheck export { CoPrimeCheck }

View File

@ -29,4 +29,4 @@ const GetEuclidGCD = (arg1, arg2) => {
return (less) return (less)
} }
module.exports = GetEuclidGCD export { GetEuclidGCD }

View File

@ -26,4 +26,4 @@ const ReverseNumber = (number) => {
return reverseNumber return reverseNumber
} }
module.exports = ReverseNumber export { ReverseNumber }

View File

@ -1,4 +1,4 @@
const { binaryExponentiation } = require('../BinaryExponentiationRecursive') import { binaryExponentiation } from '../BinaryExponentiationRecursive'
describe('BinaryExponentiationRecursive', () => { describe('BinaryExponentiationRecursive', () => {
it('should calculate 2 to the power of 10 correctly', () => { it('should calculate 2 to the power of 10 correctly', () => {

View File

@ -4,8 +4,6 @@
Find the sum of all the multiples of 3 or 5 below the provided parameter value number. Find the sum of all the multiples of 3 or 5 below the provided parameter value number.
*/ */
const readline = require('readline')
const multiplesThreeAndFive = (num) => { const multiplesThreeAndFive = (num) => {
let total = 0 let total = 0
// total for calculating the sum // total for calculating the sum
@ -17,11 +15,4 @@ const multiplesThreeAndFive = (num) => {
return total return total
} }
const rl = readline.createInterface({ export { multiplesThreeAndFive }
input: process.stdin,
output: process.stdout
})
rl.question('Enter a number: ', function (num) {
console.log(multiplesThreeAndFive(num)) // multiples3_5 function to calculate the sum of multiples of 3 and 5 within num
rl.close()
})

View File

@ -41,4 +41,4 @@ const AlternativeStringArrange = (str1, str2) => {
return outStr return outStr
} }
module.exports = AlternativeStringArrange export { AlternativeStringArrange }

View File

@ -17,4 +17,4 @@ const CheckKebabCase = (varName) => {
return pat.test(varName) && !varName.includes('_') return pat.test(varName) && !varName.includes('_')
} }
module.exports = CheckKebabCase export { CheckKebabCase }

View File

@ -17,4 +17,4 @@ const CheckPascalCase = (VarName) => {
return pat.test(VarName) return pat.test(VarName)
} }
module.exports = CheckPascalCase export { CheckPascalCase }