@trickfilm400/freeradius-config-parser
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

Package Sidebar

Install

npm i @trickfilm400/freeradius-config-parser

Weekly Downloads

17

Version

0.0.3

License

MIT

Unpacked Size

19.4 kB

Total Files

27

Last publish

Collaborators

  • trickfilm400