https://github.com/web-mech/forst
Radix Trie-Based Configuration Platform
https://github.com/web-mech/forst
Last synced: about 2 months ago
JSON representation
Radix Trie-Based Configuration Platform
- Host: GitHub
- URL: https://github.com/web-mech/forst
- Owner: web-mech
- License: mit
- Created: 2017-07-12T04:06:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-12T15:13:20.000Z (about 2 years ago)
- Last Synced: 2025-03-05T14:39:33.189Z (3 months ago)
- Language: JavaScript
- Size: 43 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# > Radix Trie Hierarchical Configurations
[](https://travis-ci.org/web-mech/forst) [](https://github.com/conventional-changelog/standard-version) [](https://conventionalcommits.org)
## Setup
Add Forst as a dependency
$ npm install --save forst
Create a folder in which your config tree(s) will live
#### Example
$ mkdir conf
## Usage
Consider the following config tree directory
/conf/
├── foo
│ └── bar
│ └── baz.json
├── test
│ ├── bar.json
│ └── foo.json -> { "enabled": false }
└── test.json -> { "enabled": true, "name": "foo" }#### Getting the base configuration:
const forst = require('forst');
forst('test', './conf').then(config => console.log(config));
console.log(config); // { "enabled": true, "name": "foo" }
#### Getting the nested configuration:
const forst = require('forst');
forst(['test', 'test/foo'], './conf').then(config => console.log(config));
console.log(config); // { "enabled": false, "name": "foo" }
If the config file is not found it will return either the values of the parent configuration if found or an empty object if nothing is found.
### API
##### Table of Contents
- [index](#index)
- [map](#map)#### index
forst
**Parameters**
- `path` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)** Config path
- `basePath` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Tree base path#### map
forstMap
**Parameters**
- `map` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Config path map
- `basePath` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Tree base path