pixl-config 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -28
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,47 +1,47 @@
1
1
  # Overview
2
2
 
3
- This module provides a simple interface to your application's JSON configuration file on disk. It will load and parse the file, and can automatically reload it when it changes (and emit an event when this happens). Command-line arguments are automatically merged in with your config (uses [pixl-args](https://www.npmjs.com/package/pixl-args)), and treated as overrides. The library also provides an easy way to determine the server's hostname and local IP address.
3
+ This module provides a simple interface to your application's JSON configuration file on disk. It will load and parse the file, and can automatically reload it when it changes (and emit an event when this happens). Command-line arguments are automatically merged in with your config (uses [pixl-args](https://www.npmjs.com/package/pixl-args)), and treated as overrides.
4
4
 
5
5
  # Usage
6
6
 
7
7
  Use [npm](https://www.npmjs.com/) to install the module:
8
8
 
9
- ```
9
+ ```sh
10
10
  npm install pixl-config
11
11
  ```
12
12
 
13
13
  Then use `require()` to load it in your code:
14
14
 
15
- ```javascript
16
- var Config = require('pixl-config');
15
+ ```js
16
+ const Config = require('pixl-config');
17
17
  ```
18
18
 
19
19
  To use the module, instantiate an object:
20
20
 
21
- ```javascript
22
- var config = new Config('conf/config.json');
21
+ ```js
22
+ let config = new Config('conf/config.json');
23
23
  ```
24
24
 
25
25
  If there is an error loading or parsing the file, an exception will be thrown, so you might want to wrap it in a try/catch.
26
26
 
27
27
  Upon success, you can access your configuration keys/values using the `get()` method:
28
28
 
29
- ```javascript
30
- var verbose = config.get('verbose');
31
- var debug = config.get('debug');
29
+ ```js
30
+ let verbose = config.get('verbose');
31
+ let debug = config.get('debug');
32
32
  ```
33
33
 
34
34
  If you just want a hash of the entire config file, call `get()` without passing a key:
35
35
 
36
- ```javascript
37
- var opts = config.get();
36
+ ```js
37
+ let opts = config.get();
38
38
  if (opts.verbose) console.log("Verbose option is set.");
39
39
  if (opts.debug) console.log("Debug option is set.");
40
40
  ```
41
41
 
42
42
  You can also set values by calling `set()` and passing both a key and a value. Example:
43
43
 
44
- ```javascript
44
+ ```js
45
45
  config.set('verbose', true);
46
46
  ```
47
47
 
@@ -57,14 +57,14 @@ Please see the [pixl-args](https://www.npmjs.com/package/pixl-args) module for m
57
57
 
58
58
  If you want the library to monitor your configuration file for live changes and automatically reload it, pass `true` as a second argument to the constructor:
59
59
 
60
- ```javascript
61
- var config = new Config('conf/config.json', true);
60
+ ```js
61
+ let config = new Config('conf/config.json', true);
62
62
  ```
63
63
 
64
64
  This uses polling, and by default it checks the file for changes every 10 seconds. The library then reloads the configuration and fires off an event you can listen for:
65
65
 
66
- ```javascript
67
- var config = new Config('conf/config.json', true);
66
+ ```js
67
+ let config = new Config('conf/config.json', true);
68
68
 
69
69
  config.on('reload', function() {
70
70
  console.log("My app's config was reloaded!");
@@ -77,24 +77,13 @@ If there is an error reloading the configuration, an `error` event is emitted (n
77
77
  To set the polling frequency, pass in the desired number of milliseconds instead of `true` as the second argument. For example, to check every five seconds pass in `5000`:
78
78
 
79
79
  ```js
80
- var config = new Config('conf/config.json', 5000);
80
+ let config = new Config('conf/config.json', 5000);
81
81
  ```
82
82
 
83
83
  To stop monitoring (for example during your app's shutdown sequence) call the `stop()` method.
84
84
 
85
85
  If you would prefer to control exactly when to check for changes, do not enable live monitoring, and instead simply call the `check()` method at any frequency you want.
86
86
 
87
- ## Server Environment
88
-
89
- The library also provides a utility method for determining the server's hostname and IP address (IPv4). These things may require asynchronous operations, so you must specify a callback function. Upon completion, the hostname will be accessible via `config.hostname` and the IP address in `config.ip` (IPv4 dot-delimited string). Example:
90
-
91
- ```javascript
92
- config.getEnv( function() {
93
- console.log("The server hostname is: " + config.hostname);
94
- console.log("The server IP is: " + config.ip);
95
- } );
96
- ```
97
-
98
87
  # License
99
88
 
100
89
  **The MIT License**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixl-config",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "A simple JSON configuration loader.",
5
5
  "author": "Joseph Huckaby <jhuckaby@gmail.com>",
6
6
  "homepage": "https://github.com/jhuckaby/pixl-config",
@@ -18,9 +18,9 @@
18
18
  "config"
19
19
  ],
20
20
  "dependencies": {
21
- "pixl-class": "^1.0.0",
21
+ "pixl-class": "^1.0.3",
22
22
  "pixl-args": "^1.0.0",
23
- "pixl-tools": "^1.0.0"
23
+ "pixl-tools": "^2.0.2"
24
24
  },
25
25
  "devDependencies": {}
26
26
  }