Total Complexity | 3 |
Complexity/F | 0 |
Lines of Code | 32 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* eslint-env node */ |
||
3 | 'use strict'; |
||
4 | |||
5 | let jsonfile = require('jsonfile'); |
||
6 | |||
7 | let resources = jsonfile.readFileSync('build/data/resources.json'); |
||
8 | let reactions = jsonfile.readFileSync('build/data/reactions.json'); |
||
9 | |||
10 | for (let i in resources) { |
||
11 | let resource = resources[i]; |
||
12 | if (resource.anti_particle) { |
||
13 | let anti = resource.anti_particle; |
||
14 | if(typeof reactions[anti+'-eV'] === 'undefined'){ |
||
15 | let key = i + '-eV'; |
||
16 | let reaction = { |
||
17 | 'reactant': {}, |
||
18 | 'product': {}, |
||
19 | 'elements': [] |
||
20 | }; |
||
21 | reaction.reactant[i] = 1; |
||
22 | reaction.reactant[anti] = 1; |
||
23 | reaction.product.eV = resource.energy * 2; |
||
24 | reactions[key] = reaction; |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 | |||
29 | jsonfile.writeFileSync('build/data/resources.json', resources, { |
||
30 | spaces: 2 |
||
31 | }); |
||
32 | jsonfile.writeFileSync('build/data/reactions.json', reactions, { |
||
33 | spaces: 2 |
||
34 | }); |
||
35 |