figuier

0.3.3 • Public • Published

Figuier

Node config with extras.

devDependency status Dependency status devDependency status

usage

var
  figuier = require('figuier'),
  config;


// Get a new config object with initial data
config  = figuier({demo: [{ foo: 'bar' }]});

// set multiple properties at once
config.set({
  meaningOfLife:  42,
  interpolation:  'foo: <%= demo.0.foo %>, baz: <%= demo.0.baz %>',
  ref: {
    foo:  config.ref('demo.0.foo'),
    none: config.ref('demo.1.foo', 'Placeholder for undefined property')
  },
  use: config.use(function () {
    return  this.get('meaningOfLife') / 2;
  });
});

// set a path property (previously referenced)
config.set('demo.0.baz', 'qux');

config.get();

Will output:

  {
    demo: [{
      foo: 'bar',
      baz: 'qux'
    }],
    meaningOfLife: 42,
    interpolation: 'foo: bar, baz: qux',
    reference: {
      foo: 'bar',
      none: 'Placeholder for undefined property'
    },
    use: 21
  }
*/

Installation

npm install figuier

API Documentation

  • Config([object data]?)
    Returns a new configuration object. If an object is provided, it's used as initial data.
  • Config().get([string path]?)
    Returns the value associated to a path or undefined. If no path is provided, all values are returned.
  • Config().set([[string path, mixed value] | object data], [bool overwrite]?)
    Set the value of a given path. If an object is provided, all properties are defined by their name.
    If overwrite is true, functional parents will be replaced by their output and/or non object parents will be turned into object.
  • Config().ref(string path, [mixed placeholder]?)
    Get a reference of a property. On reading, if provided, a placeholder is returned for undefined property.
  • Config().use(function process)
    Get a value which will use a function to output processed value.

Package Sidebar

Install

npm i figuier

Weekly Downloads

1

Version

0.3.3

License

none

Last publish

Collaborators

  • cahnory