https://github.com/beyondjs/config
A powerful and flexible configuration management library for JavaScript applications. @beyond-js/config provides dynamic processing of complex configuration objects and collections, supporting file-based configs, hierarchical structures, and real-time file watching. Ideal for large-scale projects requiring robust configuration handling.
https://github.com/beyondjs/config
Last synced: 4 months ago
JSON representation
A powerful and flexible configuration management library for JavaScript applications. @beyond-js/config provides dynamic processing of complex configuration objects and collections, supporting file-based configs, hierarchical structures, and real-time file watching. Ideal for large-scale projects requiring robust configuration handling.
- Host: GitHub
- URL: https://github.com/beyondjs/config
- Owner: beyondjs
- License: mit
- Created: 2022-12-01T13:24:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-07T13:46:29.000Z (over 1 year ago)
- Last Synced: 2025-03-20T19:37:24.179Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @beyond-js/config
A dynamic configuration processor for managing complex configuration objects and collections.
## Installation
```bash
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
```javascript
const { Config, ConfigCollection } = require('@beyond-js/config');
// Create a configuration object
const config = new Config('/path/to/config/root', {
applications: 'array',
'applications/children': 'object'
});
// Set configuration data
config.data = 'config.json';
// Access configuration properties
config.ready.then(() => {
console.log(config.value);
console.log(config.errors);
console.log(config.warnings);
});
// Create a configuration collection
class MyCollection extends ConfigCollection {
_createItem(config) {
return new MyItem(config);
}
}
const collection = new MyCollection(config);
// Process the collection
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 data
- `value`: Get the processed configuration value
- `errors`: Get configuration errors
- `warnings`: Get configuration warnings
- `valid`: Check if the configuration is valid
### ConfigCollection
- `constructor(config)`
- `config`: Get the underlying configuration object
- `errors`: Get collection errors
- `warnings`: Get collection warnings
- `valid`: Check if the collection is valid
## License
MIT © [[BeyondJS](https://beyondjs.com)]