1.0.16 • Published 4 years ago

@bravejs/routing v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

BraveJS Config

A simple package to add configration for a typescript application

Installation

npm i @bravejs/config

Usage

Set a new instance of Config class, this class take a one parameter is an object of all configration values.

var config = new Config({
    app: {
        name: 'BraveJS',
        version: 1.0.0
    }
})

Now let's say we need to read our app name.

config.get('app.name', 'defaultValue')

The above example will look for app.name value if it doesn't exists it will return defaultValue

Let's add some other configration values.

config.set('app.foo', { foo: 'bar' })

Imagine that you want to merge values with exists values of a key.

For example you want to merge app.foo value with { blah: 'blah' }.

config.merge('app.foo', { blash: 'blash' })

Let's check if app.foo exists.

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

Hmmm, what if we has an object and we want to prepend value to it, Let's just first define an object.

config.set('object', {
    name: 'Hello',
    world: 'World',
})

To prepend a value to it.

config.prepend('object', {
    test1: 'test1',
    test2: 'test2',
})

The results should be.

[
    {
        test1: 'test1',
        test2: 'test2',
    },
    {
        name: 'Hello',
        world: 'World',
    }
]

There's also a method called push it's the same usage as prepend

1.0.16

4 years ago

1.0.15

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago