2.0.1 • Published 7 years ago

y-config v2.0.1

Weekly downloads
10
License
MIT
Repository
github
Last release
7 years ago

y-config

Create public configuration for the project

node Travis Coveralls Known Vulnerabilities David Author license

Usage

Installation

npm install --save y-config

Import Module

javascript:

const Config = require("y-config");

typescript:

import Config = require("y-config");

Load Config File

const config = new Config();
config.addConfigPath('./config.json');
config.addConfigPath('./config.yaml');

Use JSON parse

const config = new Config();
config.addConfigPath('./config', 'json');

Use YAML parse

const config = new Config();
config.addConfigPath('./config', 'yaml');

Use Custom parse

const config = new Config();
config.addParser({
  format: 'ini',
  filter: /\.ini$/,
  handler: (filepath) => {
    const fs = require('fs');
    const ini = require('ini');
    return ini.parse(fs.readFileSync('./config.ini', 'utf-8'))
  }
});

Add Config Data

const config = new Config();
config.addConfig({
  baz: "foo"
});

Export Config

const config = new Config();
// ......
config.getConfig();
2.0.1

7 years ago

2.0.0

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.0

8 years ago