Primitives
Config
@stone-js/config is a deep store addressed by dotted keys. It is what the Blueprint is built on, and it stands alone for any nested configuration you want to read and write by path, with sensible defaults and deep merging.
#Standalone use
import { Config } from '@stone-js/config'
const config = Config.create({ tasks: { pageSize: 20 }, logger: { level: 'info' } })
config.get('tasks.pageSize', 50) // 20
config.get('tasks.sort', 'asc') // 'asc' (default; key absent)
config.has('logger.level') // true
config.set('tasks.pageSize', 100) // update by path#The surface
| Member | Type | Description |
|---|---|---|
| Config.create(obj) | (obj) => Config | Create a store from an object. |
| get(key, default?) | <T>(key, T?) => T | Read by dotted key, with a fallback. |
| set(key, value) | (key, value) => this | Write by dotted key. |
| has(key) | (key) => boolean | Test presence by dotted key. |
| all() | () => object | The whole store. |
| clear() | () => this | Empty the store. |
#The path helpers
The same dotted-path logic is exposed as standalone functions, useful for reading or merging plain objects without a Config instance.
import { getPath, setPath, hasPath, deepMerge } from '@stone-js/config'
getPath(obj, 'a.b.c', fallback)
setPath(obj, 'a.b.c', value)
hasPath(obj, 'a.b.c')
deepMerge(defaults, overrides)