@sapphirejs/config

0.0.15 • Public • Published

Config

A simple configuration package mostly to be used internally for Sapphire Framework.

Usage

$ npm install --save @sapphirejs/config

Imagine we have a configuration file with the following contents:

const cfg = {
  name: 'sapphire',
  secret: {
    password: 'framw123'
  }
}

We can access those configuration options:

const Config = require('@sapphirejs/config')

const config = new Config(cfg)
config.get('name') // sapphire

It even supports path syntax for deep nested object keys:

config.get('secret.password') // framw123

A default value can be passed if a key doesn't exist:

config.get('i.dont.exist', 'or maybe i do') // or maybe i do

To quickly check if a quick exists:

config.has('app.name') // true

Package Sidebar

Install

npm i @sapphirejs/config

Weekly Downloads

0

Version

0.0.15

License

MIT

Unpacked Size

3.54 kB

Total Files

6

Last publish

Collaborators

  • aleksanderkoko
  • fadion