@stlib/config
v0.0.4-r
Published
Utility for creating configs in node.js applications
Downloads
3
Maintainers
Readme
@stlib/config
Table of contents
About
stlib/config - is a library for creating configurations in your node.js applications.
Getting started
Installation
$ yarn add @stlib/config
[!IMPORTANT] Node.js 18.x+ version must be installed in your OS.
Usage
Object type for config:
ConfigType {
[key: string]: string | number;
}
Options type for config:
export interface ConfigOptionsType {
force?: boolean;
alter?: boolean;
}
Config {
constructor(path: PathLike, config: ConfigType, options?: ConfigOptionsType);
// reads current config
read(): ConfigType;
static read(path: PathLike): Promise<ConfigType>;
static readSync(path: PathLike): ConfigType;
// Get specific value from config
get(key: string): string | number;
static get(key: string, path: PathLike): Promise<string | number>;
static getSync(key: string, path: PathLike): string | number;
// If use static methods of Config class, use this function to create config before other operations
static create(path: PathLike): Promise<void>;
static createSync(path: PathLike): void;
// Update config
write(config: ConfigType): Promise<void>;
static write(path: PathLike, config: ConfigType): Promise<void>;
static writeSync(path: PathLike, config: ConfigType): void;
}
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Changelog
Project changes are writen in changelog, see the CHANGELOG.md.
We use SemVer for versioning. For the versions available, see the tags on this repository. For the versions supported, see the SECURITY.md.
Authors
License
This project is licensed under the MIT License - see the LICENSE.md