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
module.exports = DateDayDifference
export { DateDayDifference }

View File

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

View File

@ -32,4 +32,4 @@ const LowerCaseConversion = (inputString) => {
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
*/
(function test () {
const newAVL = new AVLTree()
const size = Math.floor(Math.random() * 1000000)
let uniques = 0
let i, temp, j
const array = []
for (i = 0; i < size; i++) {
temp = Math.floor(Math.random() * Number.MAX_VALUE)
if (newAVL.add(temp)) {
uniques++
array.push(temp)
}
}
if (newAVL.size !== uniques) {
throw new Error('elements not inserted properly')
}
const findTestSize = Math.floor(Math.random() * uniques)
for (i = 0; i < findTestSize; i++) {
j = Math.floor(Math.random() * uniques)
if (!newAVL.find(array[j])) {
throw new Error('inserted elements not found')
}
}
const deleteTestSize = Math.floor(uniques * Math.random())
for (i = 0; i < deleteTestSize; i++) {
j = Math.floor(Math.random() * uniques)
temp = array[j]
if (newAVL.find(temp)) {
if (!newAVL.remove(temp)) {
throw new Error('delete not working properly')
}
}
}
})()
// (function test () {
// const newAVL = new AVLTree()
// const size = Math.floor(Math.random() * 1000000)
// let uniques = 0
// let i, temp, j
// const array = []
// for (i = 0; i < size; i++) {
// temp = Math.floor(Math.random() * Number.MAX_VALUE)
// if (newAVL.add(temp)) {
// uniques++
// array.push(temp)
// }
// }
// if (newAVL.size !== uniques) {
// throw new Error('elements not inserted properly')
// }
// const findTestSize = Math.floor(Math.random() * uniques)
// for (i = 0; i < findTestSize; i++) {
// j = Math.floor(Math.random() * uniques)
// if (!newAVL.find(array[j])) {
// throw new Error('inserted elements not found')
// }
// }
// const deleteTestSize = Math.floor(uniques * Math.random())
// for (i = 0; i < deleteTestSize; i++) {
// j = Math.floor(Math.random() * uniques)
// temp = array[j]
// if (newAVL.find(temp)) {
// if (!newAVL.remove(temp)) {
// throw new Error('delete not working properly')
// }
// }
// }
// })()
module.exports = AVLTree
export { AVLTree }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
const { binaryExponentiation } = require('../BinaryExponentiationRecursive')
import { binaryExponentiation } from '../BinaryExponentiationRecursive'
describe('BinaryExponentiationRecursive', () => {
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.
*/
const readline = require('readline')
const multiplesThreeAndFive = (num) => {
let total = 0
// total for calculating the sum
@ -17,11 +15,4 @@ const multiplesThreeAndFive = (num) => {
return total
}
const rl = readline.createInterface({
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()
})
export { multiplesThreeAndFive }

View File

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

View File

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

View File

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