x-configuration
v0.2.2
Published
Another configuration constructor to help manage key value pairs. Allows for inner configuration lookups
Downloads
2
Maintainers
Readme
x-configuration
Another configuration constructor to help manage key value pairs. Allows for inner configuration lookups.
$ npm install x-configuration
$ bower install x-configuration
Usage
var Configuration = require("x-configuration");
var config = new Configuration({
hello: "<%= config.world %>",
world: 42,
nested: {
coolStuff: "So cool",
values: {
abc: "<%= nested.coolStuff %>",
collection: [
23,
"<%= values.abc %>"
]
}
}
});
console.log(config.get("world"));
console.log(config.accessor().world);
// > 42
console.log(config.get("hello"));
console.log(config.accessor().hello);
// > 42
console.log(config.get("nested.coolStuff"));
console.log(config.accessor().nested.coolStuff);
// > So cool
console.log(config.get("nested.values.abc"));
console.log(config.accessor().nested.values.abc);
// > So cool
console.log(config.get("nested.values.collection[0]"));
console.log(config.accessor().nested.values.collection[0]);
// > 23
console.log(config.get("nested.values.collection[1]"));
console.log(config.accessor().nested.values.collection[1]);
// > So cool
config.set("nested.coolStuff", "Had enough?"); // Yes...
console.log(config.get("nested.values.collection[1]"));
console.log(config.accessor().nested.values.collection[1]);
// > Had enough?