2.2.0 • Published 4 years ago

clean-config v2.2.0

Weekly downloads
12
License
-
Repository
-
Last release
4 years ago

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);
2.2.0

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago