@smiilliin/settings
v1.0.12
Published
Easier to load and write settings
Downloads
16
Maintainers
Readme
Settings - Easier to load and write settings
Usage
Initialization
Initialize setting class
import SettingManager from "@smiilliin/settings";
const settingManager = new SettingManager("test-app");
Set
Set setting file
settingManager.set("settings.json", {
test: "hello world",
});
Set option
settingManager.setOption("settings.json", "test", "hello world");
Delete
Delete file
settingManager.delete("settings.json");
Delete option
settingManager.deleteOption("settings.json", "test");
Load
Create app directory and load setting
console.log(settingManager.load("settings.json"));
With default settings
console.log(settingManager.load("settings.json", { test2: "hi" }));
Watch
Watch setting file
settingManager.watch("setting.json", (setting) => {
console.log(setting);
});
With default settings
settingManager.watch(
(setting) => {
console.log(setting);
},
{ test: "hello world" }
);
Unwatch
Release watch
settingManager.unwatch("setting.json");
Release all watch
settingManager.unwatchAll();
CreateDir
Create app directory(not neccessary if already loaded setting)
settingManager.createDir();
GetAppdir
Get app directory
console.log(settingManager.getAppdir());