https://github.com/lvchengbin/config
Config object management.
https://github.com/lvchengbin/config
Last synced: 11 months ago
JSON representation
Config object management.
- Host: GitHub
- URL: https://github.com/lvchengbin/config
- Owner: LvChengbin
- License: mit
- Created: 2018-02-02T07:42:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T15:51:36.000Z (over 7 years ago)
- Last Synced: 2025-08-31T05:26:53.364Z (11 months ago)
- Language: JavaScript
- Size: 144 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Config
A simple library for creating and managing config object.
## Start
To install the package with `npm`.
```js
$ npm i @lvchengbin/config --save
```
To use the package in nodejs:
```js
const Config = require( '@lvchengbin/config' );
```
Or using the package as an ES6 module:
```js
import Config from '@lvchengbin/config';
```
## Usage
To create a config object by default config value;
```js
import Config from '@lvchengbin/config';
const config = new Config( {
baseUrl : 'js/lib',
paths : {
app : '../app'
}
} );
config.set( 'baseUrl', 'js/base' ); // set new value for baseUrl
config.set( 'paths.app', '../../app' ); // set new value for paths.app
// replace the whole config object
config.set( {
baseUrl : 'js',
paths : {
lib : '../lib'
}
} );
config.get(); // to get the whole config object
config.get( 'baseUrl' ); // get the value of baseUrl
config.get( 'paths.app' ); // get the value of paths.app
```