| |
| |
| |
|
|
| const fs = require('fs'); |
| const path = require('path'); |
|
|
| const SEI_PATH = path.join(__dirname, 'sei.json'); |
|
|
| |
| function ensureSEI() { |
| if (!fs.existsSync(SEI_PATH)) { |
| fs.writeFileSync(SEI_PATH, JSON.stringify({ |
| seiVersion: "v0.1", |
| species: [] |
| }, null, 2)); |
| } |
| } |
|
|
| |
| function registerSpecies(mu) { |
| ensureSEI(); |
|
|
| const sei = JSON.parse(fs.readFileSync(SEI_PATH, 'utf8')); |
|
|
| |
| const speciesEntry = { |
| id: mu.id, |
| length: mu.payload.length, |
| type: mu.payload.type, |
| compiledAt: mu.compiledAt, |
| ecologicalClass: "meaning-unit", |
| driftPotential: 0, |
| stability: "deterministic" |
| }; |
|
|
| sei.species.push(speciesEntry); |
|
|
| fs.writeFileSync(SEI_PATH, JSON.stringify(sei, null, 2)); |
|
|
| return sei; |
| } |
|
|
| module.exports = { registerSpecies }; |
|
|