config-xyz
A configuration manager for NodeJS. support nodejs & typescript
- dot prop set/get
- updated event listener
- load values from .js/yml/json files.
break changes
- #### 2.0.0
Config
is not extendsEventEmitter2
any more, useConfig.prototype.events
instead. EventEmitter2 instance will be initialized called first time (listen any events)
Note
load values from .js file:
- ignore require.cache
- load js files with vm2 (default), or provide an option
{ loadJsFileWithVm: false }
to skip it. - if load with vm2
- cannot require any module or access any global variables, but only process.env
install
npm install config-xyz --save
// yarn add config-xyz
Usage
more examples are in src/tests/test_config.ts
; config.set'xxx', 1config.merge assert.strictEqual1, config.get'xxx'assert.strictEqual1, config.get'not exist and return default', 1config.set'xxx.aaa', 1assert.strictEqual1, config.get'xxx.aaa'assert.strictEqual1, config.get'xxx'.aaa // Eventconfig.on'update',// wild Event powered by Eventemitter2config.on'update:xxx.**',config.set'xxx.aa', 1
API