3.0.2 • Published 9 years ago

refig v3.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
9 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

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.0

10 years ago