Skip to content

specla/config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@specla/config

npm version Build Status Coverage Status Dependency Status Standard - JavaScript Style Guide

Manage configuration objects with ease.

Install

npm install @specla/config

Usage

import Config from '@specla/config'

const config = new Config({
  'my.config.key': 'some value...'
})

// Access property in the config
config.get('my.config.key') // returns 'some value...'

// Access part of config property
config.get('my') // returns { config: { key: 'some value...' } }

// Set or update a config property value
config.set('my.config.key', 'updated value...')

// Delete a config property
config.unset('my.config.key')

// Merge current config with new config
config.merge({
  'my.config.newKey': 'other key...'
})

Functional properties

Specla config ships with functional properties which is a dynamic property that has a relation to an other config property.

const config = new Config({
  'normal.prop': 'test',
  'func.prop': config => config.get('normal.prop') + ' functional property'
})

config.get('func.prop') // will return "test functional property"