@vanesyan/config

Simple in memory key-value configuration manager


Keywords
conf, config, configuration, manager
License
MIT
Install
npm install @vanesyan/config@1.0.0

Documentation

@vanesyan/config

Simple in-memory config storage
Unix Build

Install

$ npm install --save @vanesyan/config

Usage

const Config = require('@vanesyan/config')
const config = new Config()

config.set('foo.bar', 'baz') // => { foo: { bar: 'baz' } }
config.get('foo.bar') // => 'baz'
config.has('foo') // => true

config.set('foo.baz', 'bar') // config { foo: { bar: 'baz', baz: 'bar' } }
config.delete('foo.bar') // config { foo: { baz: 'bar' } }

config.get() // => { foo: { baz: 'bar' } }

API

Config([config])

config

Initial storage
Type: Object

Config#get([key]) => *|null

Get value by the key. If key is omitted returns config storage. Return null if nothing is matched.

Config#has(key) => void

Check if config has the value under specified key

Config#set(key, val) => void

Set val under specified key. If type of key is object, reset the config storage to that object.

Config#delete([key]) => void

Delete value specified by key. If key is omitted delete the whole config storage.

Config.size

Size of the config

key

Path of property in config object, using Config.KEY_PATH_SPLIT_SYMBOL to separate nested keys
Type: string

val

Value to set under specified key
Type: any

License

Released under the MIT license.