3.0.2 • Published 8 years ago

refig v3.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Refig

Manage configuration files with Promise objects.

Refig is a library for reading and parsing configuration files. It handles directories, uses a parser of your choice, caches configurations, and is based on top of Promise objects (for a nice asynchronous flow).

Installation

$ npm install --save refig

Usage

import Refig from 'refig';
const refig = new Refig();

API

Refig

Kind: global class

new Refig(opts)

ParamTypeDescription
optsObjectOptions

refig.load

Read and parse a configuration file.

Kind: instance property of Refig

ParamTypeDescription
pathArray | StringA string (or array of strings) of a path.

refig.merge

Fetch multiple configurations and merge them.

Kind: instance property of Refig

ParamTypeDescription
pathArray | StringA string (or array of strings) of a path.

refig.pick

Pick a single attribute out of a file.

Kind: instance property of Refig

ParamTypeDescription
pathArray | StringA string (or array of strings) of a path.
nameStringName of the attribute to pick.

refig.purge

Purge a file from the cache.

Kind: instance property of Refig

ParamTypeDescription
pathArray | StringA string (or array of strings) of a path.

refig.set

Set an option

Kind: instance property of Refig

Examples

Since Refig is designed around Promise objects, you can do some pretty interesting things.

refig.merge('~/foo/bar.json', '/usr/share/foo/bar.json')
.then(opts => Object.assign(opts, refig.pick('package.json', 'foo')))
.then(opts => {
  // two configurations + package.json settings, all merged.
});

Credits

Jamen Marz
@jamen

License

MIT © Jamen Marzonie

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.0.0

9 years ago