@habemus-papadum/config
v0.0.2
Published
Shared configuration utilities
Readme
@habemus-papadum/config
Shared configuration utilities.
Installation
npm install @habemus-papadum/configUsage
import {
mergeConfig,
createConfig,
getConfigValue,
hasConfigValue,
defaults,
} from "@habemus-papadum/config";
// Merge configurations
const config = mergeConfig(defaults, {
env: "production",
api: { url: "https://api.example.com" },
});
// Create immutable config
const frozenConfig = createConfig({ debug: true });
// Access nested values
getConfigValue(config, "api.url"); // "https://api.example.com"
// Check if value exists
hasConfigValue(config, "api.url"); // trueAPI
mergeConfig(...configs: Config[]): Config
Deep merges multiple configuration objects. Later configs override earlier ones.
createConfig<T>(config: T): Readonly<T>
Creates a frozen (immutable) copy of the configuration.
getConfigValue(config: Config, path: string): unknown
Gets a nested value using dot notation (e.g., "api.url").
hasConfigValue(config: Config, path: string): boolean
Checks if a value exists at the given path.
defaults
Default configuration values:
env: "development"debug: falseversion: "0.0.1"
License
ISC
