@trickfilm400/freeradius-config-parser
v0.0.4
Published
freeradius-config-parser
Downloads
19
Maintainers
Readme
freeradius-config-parser
This project exposes a simple clas API to read and write freeradius config files.
Example Parsing:
import { File } from '@trickfilm400/freeradius-config-parser';
const obj = new File('block {\nsetting = yes\n}');
const result = obj.getElements();
//result =
// [
// Block {
// children: [Value { key: 'setting', operator: '=', value: 'yes' }],
// names: ['block'],
// },
// ];
//or mostly useful: specify file path of freeradius config
const obj = new File('/etc/freeradius/3.0/sites-available/default', /*parseDirectly*/ true);
//without 'parseDirectly'=true
obj.parse();
Example Writing:
//to save a new file
const obj = new File("./file.conf", /*writeDirectly=*/false, [
new Block("block", [
new Value("setting", "=", "yes"),
new Blank(1),
new Comment("# comment"),
]),
]);
obj.write();
© 2024
Created with ♥ by typescript-project-scaffolding