-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (41 loc) · 1.49 KB
/
Copy pathindex.js
File metadata and controls
47 lines (41 loc) · 1.49 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
/* eslint quote-props: 0 */
import React from 'react';
import * as Explanation from './explanations';
import * as Param from './parameters';
import * as ExtraInfo from './extra-info';
import * as Controller from './controllers';
import * as Pseudocode from './pseudocode';
import * as Instructions from './instructions';
// Allowing dyanmic module injection
/* eslint import/namespace: ["error", { "allowComputed": true }] */
import algorithmMetadata from './masterList.js';
const getAlgorithms = (meta) =>
Object.fromEntries(
Object.entries(meta).map(([id, m]) => {
const ParamModule = Param[m.paramKey];
const explanationModule = Explanation[m.explanationKey];
const instructionsModule = Instructions[m.instructionsKey];
const extraInfoModule = ExtraInfo[m.extraInfoKey];
const pseudocodeValue = Object.fromEntries(
Object.entries(m.pseudocode).map(([mode, key]) => [mode, Pseudocode[key]])
);
const controllerValue = Object.fromEntries(
Object.entries(m.controller).map(([mode, key]) => [mode, Controller[key]])
);
return [
id,
{
name : m.name,
category: m.category,
explanation: explanationModule,
param: <ParamModule />,
instructions: instructionsModule,
extraInfo: extraInfoModule,
pseudocode: pseudocodeValue,
controller: controllerValue,
},
];
})
);
const allalgs = getAlgorithms(algorithmMetadata);
export default allalgs;