clean-config

2.2.0 • Public • Published

clean-config

A quick package to load config files in a simple & clean way.

Versions

  • 2.2.0, 2020-08-19, AMV : Hacked out new MagicMap features, but didn’t doc it yet.
  • 2.1.0, 2020-08-18, AMV : Added KEY swaps, but didn’t doc it yet.
  • 2.0.2, 2020-08-17, AMV : Changed to brackets for keys, and fixed comments to longer clash with URLs.
  • 1.0.1, 2020-06-24, AMV : First publish.

Usage

Here’s an example of a config file’s syntax:

// This is a comment line.
[SomeKey1]     Here is a value to assign to SomeKey.
[AnotherKey2]  Here's a value to assign to a different key.

Loading that file in using clean-config returns:

{
  "SomeKey1": "Here is a value to assign to SomeKey.",
  "AnotherKey2": "Here's a value to assign to a different key."
}

And here’s how to use the package:

const cleanConfig = require('clean-config');
 
// Basic transforms between Text and ConfigObject:
const cfg = cleanConfig.fromText('[key1]Aaa\n[key2]Bbb');
const txt = cleanConfig.toText(cfg);
 
// FS helpers:
const cfg = cleanConfig.readSync('/some/path/mycfgfile.txt');
const cfg = cleanConfig('/some/path/mycfgfile.txt'); // short syntax
cleanConfig.writeSync('/some/path/mycfgfile.txt', cfg);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.2.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.2.0
    0
  • 2.1.0
    0
  • 2.0.2
    0
  • 1.0.1
    0

Package Sidebar

Install

npm i clean-config

Weekly Downloads

0

Version

2.2.0

License

none

Unpacked Size

13.5 kB

Total Files

9

Last publish

Collaborators

  • wv-coder