1.0.0 • Published 3 years ago

@softvisio/config v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

: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 or file: URL (as <string> or <URL> object).
  • options? <Object>:
    • resolve <string> | <URL> File URL to resolve config path. Usually import.meta.url is used.
    • json5 <boolean> Parse JSON configs using json5 parser.
    • all <boolean> For YAML configs returns all documants as <Array>.
  • Returns: <any> Config data.

config.write( path, data, options? )

  • path <string> | <URL> Path paramenter can be filesystem path or file: URL (as <string> or <URL> object).
  • data <any> Config data to write.
  • options? <Object>:
    • resolve <string> | <URL> File URL to resolve config path. Usually import.meta.url is used.
    • readable <boolean> Pretty print JSON configs.
1.0.0

3 years ago