json-config-read

Tool for easily reading JSON configuration folders

Usage no npm install needed!

<script type="module">
  import jsonConfigRead from 'https://cdn.skypack.dev/json-config-read';
</script>

README

json-config-read

install:

npm i --save json-config-read

API

Table of Contents

ConfigReadOptions

Config read options type

Parameters

allowDirectories

True if directories can be read merging all files inside them

Type: boolean

rootPath

The root path to use. If unspecified, current directory is used.

Type: string

extensions

The file extensions that are parseable.

Type: Object<string, boolean>

default

The default options.

Type: Partial<ConfigReadOptions>

configReadSync

Reads a configuration file or directory synchronously.

Parameters

  • configPath string Path of the file or directory to load
  • options Partial<ConfigReadOptions> The options (optional, default ConfigReadOptions.default)

Returns any The loaded data

configReadAsync

Reads a configuration file or directory asynchronously.

Parameters

  • configPath string Path of the file or directory to load
  • options Partial<ConfigReadOptions> The options (optional, default ConfigReadOptions)

Returns Promise<any> A promise that resolves the loaded data

configsListAsync

Lists all configurations in a directory, asynchrounously.

Parameters

  • folderPath string Path of the folder that contains multiple configurations to list
  • options Partial<ConfigReadOptions> The options (optional, default ConfigReadOptions)

Returns Promise<Array<string>> A promise that resolves a list of full paths

configsListSync

Lists all configurations in a directory, synchrounously.

Parameters

  • folderPath string Path of the folder that contains multiple configurations to list
  • options Partial<ConfigReadOptions> The options (optional, default ConfigReadOptions)

Returns Array<string> A list of all full paths of all configurations

configsReadManyAsync

Reads all the configurations contained in a folder to a map object

Parameters

  • folderPath string Path of the folder that contains multiple configurations to load
  • options Partial<ConfigReadOptions> The options (optional, default ConfigReadOptions)

Returns Promise<Object<string, any>> A promise that resolves a map of loaded configurations

configsReadManySync

Reads all the configurations contained in a folder to a map object

Parameters

  • folderPath string Path of the folder that contains multiple configurations to load
  • options Partial<ConfigReadOptions> The options (optional, default ConfigReadOptions)

Returns Object<string, any> A map of loaded configurations