const Exp = {}; Exp.Fs = require('fs'); Exp.ConfigParser = require('./config-ini-parser').ConfigIniParser; // https://stackoverflow.com/a/69049676 Exp.importAll = function importAll(){ delete this.importAll; Object.assign(global, this); }; Exp.ParseMeta = (Raw) => { let Mid = { Meta: "", Macros: "" }; let Data = { Meta: {}, Macros: {}, IsToml: false }; const Lines = Raw.trim().split('\n'); if (Lines[0].trim() === '+++' && Lines.slice(-1)[0].trim() === '+++') { Data.IsToml = true; Lines = Lines.slice(1, -1); } for (let i=0; i { const Items = new ConfigParser().parse(Mid[Type]).items(); Items.forEach((Item) => { Data[Type][Item[0]] = Item[1]; }); }); return Data; }; module.exports = Exp;