y-config
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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();

Package Sidebar

Install

npm i y-config

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

12.7 kB

Total Files

8

Last publish

Collaborators

  • arylo