A library for reading, writing, and watching ini files for changes
npm install @mdaemon/ini-file-cache    
Not applicable to a browser context.
$ npm install @mdaemon/ini-file-cache --save
javascript
const IniFileCache = require("@mdaemon/ini-file-cache");
`
Node Modules #
`javascript
import IniFileCache from "@mdaemon/ini-file-cache";
`
$3
`javascript
// Create a new IniFileCache instance
const iniCache = new IniFileCache("/path/to/file/", "config.ini");// Read a value from the ini file
const value = iniCache.getSetting("section", "key", "defaultValue");
console.log(value);
// Write a value to the ini file
iniCache.setSetting("section", "key", "new value");
// Save changes to the file
iniCache.save();
// Watch for changes in the ini file
iniCache.watch();
// Stop watching the file
iniCache.unwatch();
// Get all sections
const sections = iniCache.getSections();
console.log(sections);
// Get all keys in a section
const keys = iniCache.getKeys("section");
console.log(keys);
// Check if a section exists
const sectionExists = iniCache.hasSection("section");
console.log(sectionExists);
// Check if a key exists in a section
const keyExists = iniCache.hasKey("section", "key");
console.log(keyExists);
// Remove a key from a section
iniCache.removeKey("section", "key");
// Remove an entire section
iniCache.removeSection("section");
// Reload the file from disk
iniCache.reload();
iniCahe.listener.on("change", (filename) => { });
iniCache.listener.on("error", (error) => { });
iniCache.listener.on("reload", (filePath) => { });
iniCache.listener.on("save", (filePath) => { });
``Published under the LGPL-2.1 license.
Published by
MDaemon Technologies, Ltd.
Simple Secure Email
https://www.mdaemon.com