@slimio/config
Advanced tools
Comparing version 0.10.0 to 0.11.0
{ | ||
"name": "@slimio/config", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "SlimIO Reactive JSON Config loaded", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublish": "pkg-ok", | ||
"prepublishOnly": "pkg-ok", | ||
"test": "ava --verbose", | ||
"doc": "jsdoc -c ./jsdoc.json -r", | ||
"coverage": "nyc ava", | ||
"version": "conventional-changelog -i CHANGELOG.md -s", | ||
"report": "nyc report --reporter=html" | ||
@@ -58,2 +59,3 @@ }, | ||
"ava": "^0.25.0", | ||
"conventional-changelog-cli": "^2.0.11", | ||
"eslint": "^5.9.0", | ||
@@ -70,5 +72,5 @@ "husky": "^1.2.0", | ||
"lodash.set": "^4.3.2", | ||
"node-watch": "^0.5.8", | ||
"node-watch": "^0.5.9", | ||
"zen-observable": "^0.8.11" | ||
} | ||
} |
@@ -52,2 +52,5 @@ # Config | ||
// Payload getter will return a deepClone with all configuration properties | ||
console.log(cfg.payload); | ||
await cfg.close(); | ||
@@ -58,2 +61,4 @@ } | ||
> **Note:** config.json should exist (if not, it will throw an Error). Look at `createOnNoEntry` option for more information ! | ||
## Events | ||
@@ -71,3 +76,3 @@ Configuration class is extended by a Node.js EventEmitter. The class can trigger several events: | ||
### constructor<T>(configFilePath: string, options?: Config.ConstructorOptions) | ||
### constructor< T >(configFilePath: string, options?: Config.ConstructorOptions) | ||
Create a new Configuration instance | ||
@@ -97,6 +102,8 @@ ```js | ||
```js | ||
const { strictEqual } = require("assert"); | ||
const cfg = new Config("./path/to/file.json"); | ||
assert.equal(cfg.configHasBeenRead, false); // true | ||
strictEqual(cfg.configHasBeenRead, false); // true | ||
await cfg.read(); | ||
assert.equal(cfg.configHasBeenRead, true); // true | ||
strictEqual(cfg.configHasBeenRead, true); // true | ||
``` | ||
@@ -117,3 +124,3 @@ | ||
### get<H>(fieldPath: string, depth?: number): H | ||
### get< H >(fieldPath: string, depth?: number): H | ||
Get a value from a key (field path). | ||
@@ -130,3 +137,5 @@ | ||
### set<H>(fieldPath: string, fieldValue: H): void; | ||
If the retrieved value is a JavaScript object, you can limit the depth by setting `depth` option. | ||
### set< H >(fieldPath: string, fieldValue: H): void; | ||
Set a given field in the configuration. | ||
@@ -133,0 +142,0 @@ |
47215
9
204
15
Updatednode-watch@^0.5.9