mirror of
https://github.com/chemistry-software/Periodic-Table-JSON.git
synced 2026-11-07 09:17:31 +00:00
* added: group, wxpos (wide x position), wypos(wide y position), block * update: README.md
21 lines
557 B
JavaScript
21 lines
557 B
JavaScript
const fs = require('fs');
|
|
|
|
const json = fs.readFileSync('../PeriodicTableJSON.json');
|
|
|
|
const Periodic = JSON.parse(json).elements;
|
|
|
|
const lookup = Periodic.reduce((acc, curr) => {
|
|
const name = curr.name.toLowerCase();
|
|
acc.order.push(name);
|
|
acc[name] = curr;
|
|
return acc;
|
|
}, { order: [] });
|
|
|
|
if(!!lookup.order.length) {
|
|
fs.writeFile('../periodic-table-lookup.json', JSON.stringify(lookup, null, 4), () => {
|
|
console.log('Periodic lookup successfully created');
|
|
})
|
|
} else {
|
|
throw new Error('Problem creating lookup file');
|
|
}
|