@beyond-js/config
A dynamic configuration processor for managing complex configuration objects and collections.
Installation
npm install @beyond-js/config
Features
- Dynamic processing of configuration objects and arrays
- File-based configuration support
- Hierarchical configuration structure
- Error and warning handling
- Watching for file changes
Usage
const { Config, ConfigCollection } = require('@beyond-js/config');
const config = new Config('/path/to/config/root', {
applications: 'array',
'applications/children': 'object'
});
config.data = 'config.json';
config.ready.then(() => {
console.log(config.value);
console.log(config.errors);
console.log(config.warnings);
});
class MyCollection extends ConfigCollection {
_createItem(config) {
return new MyItem(config);
}
}
const collection = new MyCollection(config);
collection.ready.then(() => {
console.log(collection.size);
for (const [key, item] of collection) {
console.log(key, item);
}
});
API
Config
constructor(rootPath, branchesSpecs)
data
: Get/set the configuration datavalue
: Get the processed configuration valueerrors
: Get configuration errorswarnings
: Get configuration warningsvalid
: Check if the configuration is valid
ConfigCollection
constructor(config)
config
: Get the underlying configuration objecterrors
: Get collection errorswarnings
: Get collection warningsvalid
: Check if the collection is valid
License
MIT © [BeyondJS]