1.0.3 • Published 8 months ago

letsconfig v1.0.3

Weekly downloads
-
License
LGPL-3.0+
Repository
github
Last release
8 months ago

letsConfig

letsConfig is a class for working with a configuration file.

Table of Contents

letsConfig

  • The letsConfig class allows you to automate work with the application configuration file.

  • The index.js bundle works well in Node.js. It is used by default when you require('letsconfig') in Node.js.

Getting started

Node.js

Install letsconfig using npm:

npm install letsconfig

And import it as a CommonJS module:

const letsConfig = require('letsconfig');

Examples

Here are some examples of how to use letsConfig.

Constructor

The constructor method takes the following optional parameters:

  • options - an object with arbitrary data. Keys and values ​​will be assigned to the class during the initialization process. By default, it takes the value of an empty object: options = {}. If a configuration file with a JSON structure is read, the keys from this file will have priority for assigning variables.

  • dir - a string specifying the absolute path to the directory containing the configuration file. Example: /home/username/sites/somedomain/.

  • fileName - a string specifying the name of the configuration file with the json extension.

let config = new letsConfig({
		host: 'localhost',
		port: 8000
	},
	'/home/username/sites/somedomain/',
	'configuration.json');
console.log(config.host);
console.log(config.port);

// or

let conf = new letsConfig();
console.log(conf);

writeConfigFile

The writeConfigFile function writes the current class data to a JSON configuration file.

config.writeConfigFile();

License

GNU Lesser General Public License (3.0 or any later version). Please take a look at the LICENSE file for more information.

1.0.3

8 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago