2.0.0 • Published 9 years ago
@vanesyan/config v2.0.0
@vanesyan/config
Simple in memory configuration manager.
Installation
The easiest way to get the package is to install it through npm
$ npm install @vanesyan/configExample
const config = new Config()
config.set('db.conn.port', 8912)
console.log(config.get('db.conn.port')) // => 8912Application Programming Interface
Config()
const config = new Config()Config#size
Returns config size (entries count).
config.size // => numberConfig#get(keyPath)
Returns value associated to the keyPath if exists otherwise returns
undefined. Returns entire config keyPath is omitted.
config.get('app.auth.secret') // => value or undefinedConfig#set(keyPath, val)
Set value under specified keyPath in config. Set the entire config, if
keyPath is an object and val is omitted.
config.set('app.auth.secret', 'Your secret here!') // => undefinedConfig#delete(keyPath)
Removes the specified element by keyPath from the config. Removes the whole
config, if keyPath is omitted. Returns true if it was successfully removed
from config, otherwise false.
config.delete('app.auth.secret') // => booleanConfig#has(keyPath)
Check whether an element with specified keyPath exists or not.
Returns true if exists, otherwise false.
config.has('app.auth.secret') // => booleanLicence
Released under the MIT licence.