config_file.js
TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

ConfigFile.js

A config file management library for Node.js.

Installation

npm i config_file.js

Usage

const { ConfigFile } = require("config_file.js");

const config = new ConfigFile("./config.json", {});

run();

async function run() {
    await config.load(); // or just config.loadSync();

    config.set("a", 2); // { "a": 2 }
    config.set("b", 4); // { "a": 2, "b": 4 }

    config.get("c").set("d", []); // { "a": 2, "b": 4, "c": { "d": [] } }
    config.get("c", "d").add(6); // { "a": 2, "b": 4, "c": { "d": [6] } }

    console.log(config.get("c", "d", 0).getValue()); // Output: 6

    await config.save(); // or just config.saveSync();
}

Also, you can edit and save in a single line.

await config.set("key", "value").save();

Readme

Keywords

Package Sidebar

Install

npm i config_file.js

Weekly Downloads

105

Version

1.3.2

License

MIT

Unpacked Size

55.9 kB

Total Files

17

Last publish

Collaborators

  • yuko1101