0.3.3 • Published 9 years ago

figuier v0.3.3

Weekly downloads
4
License
-
Repository
github
Last release
9 years ago

#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.
0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago