1.0.0 • Published 4 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/configUsage
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.urlis used.json5<boolean> ParseJSONconfigs usingjson5parser.all<boolean> ForYAMLconfigs 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.urlis used.readable<boolean> Pretty printJSONconfigs.
1.0.0
4 years ago