figuier
Node config with extras.
Last updated 5 years ago by cahnory .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install figuier 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.3.3                                ...           latest (5 years ago)

6 Versions

  • 0.3.3                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |