-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalgorithmLoader.js
More file actions
47 lines (42 loc) · 1.22 KB
/
algorithmLoader.js
File metadata and controls
47 lines (42 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Utility script to dynamically load algorithms from the algorithms folder
export async function loadAlgorithms() {
const algorithms = {};
// Fetch the list of algorithm files dynamically
const algorithmFiles = await fetchAlgorithmList();
for (const file of algorithmFiles) {
try {
const module = await import(`./algorithms/${file}`);
algorithms[module.default.name] = module.default;
} catch (error) {
console.error(`Failed to load algorithm from ${file}:`, error);
}
}
return algorithms;
}
// Function to fetch the list of algorithm files
async function fetchAlgorithmList() {
return [
'bubbleSort.js',
'insertionSort.js',
'selectionSort.js',
'mergeSort.js',
'quickSort.js',
'heapSort.js',
'shellSort.js',
'countingSort.js',
'radixSort.js',
'cocktailShakerSort.js',
'gnomeSort.js',
'bogoSort.js',
'cycleSort.js',
'combSort.js',
'pancakeSort.js',
'stoogeSort.js',
'bitonicSort.js',
'oddEvenSort.js',
'timSort.js',
'pigeonholeSort.js',
'beadSort.js',
'bucketSort.js'
];
}