@zodal/dials-store-env
v0.1.0
Published
Environment-variable LayerStore for zodal-dials (a high-precedence, read-mostly scope)
Readme
@zodal/dials-store-env
Environment-variable LayerStore for zodal-dials — a high-precedence, read-only scope.
npm i @zodal/dials-store-env @zodal/dials-coreimport { createEnvStore } from '@zodal/dials-store-env';
const env = createEnvStore({
prefix: 'MYAPP',
keys: ['editor.fontSize', 'flags.beta'], // env is key-driven
});
// process.env.MYAPP_EDITOR__FONT_SIZE = "18", MYAPP_FLAGS__BETA = "true"
await env.load(); // → { 'editor.fontSize': 18, 'flags.beta': true }| Capability | | |---|---| | readable | ✅ | | writable | ❌ (read-only) | | watchable | ❌ |
- Key → env var:
editor.fontSize(prefixMYAPP) →MYAPP_EDITOR__FONT_SIZE(./-//→__, camelCase →_, uppercased). The mapping is not invertible; the store throws at construction if two keys collide on one var. - Coercion (
defaultCoerce) is lossy-safe:true/false, round-trippable numbers, and JSON objects/arrays are parsed; leading-zero / big-int / signed-zero strings are kept as strings. Override per use viacoerce.
Part of the zodal-dials ecosystem.
