1.0.0 • Published 3 years ago
@softvisio/config v1.0.0
:information_source: Please, see the full project documentation here: https://softvisio.github.io/config/.
Introduction
Read / write config files, based on file extension.
Install
npm i @softvisio/config
Usage
import config from "@softvisio/config";
const data = config.read("cfg.yaml");
const data = config.read("#resources/cfg.yaml", { resolve: import.meta.url });
config.write("cfg.json", data, { readable: true });
config.read( path, options? )
path
<string> | <URL> Path paramenter can be filesystem path orfile:
URL (as <string> or <URL> object).options?
<Object>:resolve
<string> | <URL> File URL to resolve config path. Usuallyimport.meta.url
is used.json5
<boolean> ParseJSON
configs usingjson5
parser.all
<boolean> ForYAML
configs returns all documants as <Array>.
- Returns: <any> Config data.
config.write( path, data, options? )
path
<string> | <URL> Path paramenter can be filesystem path orfile:
URL (as <string> or <URL> object).data
<any> Config data to write.options?
<Object>:resolve
<string> | <URL> File URL to resolve config path. Usuallyimport.meta.url
is used.readable
<boolean> Pretty printJSON
configs.
1.0.0
3 years ago