Neck Protection Mandate

    @brainhubeu/hadron-json-provider

    1.0.0 • Public • Published

    Installation

    npm install @brainhubeu/hadron-json-provider --save

    More info about installation

    Overview

    JSON Provider allows you to automatically load multiple files as JSON object, with file names as object keys, and files data as object values. Currently we support following extensions:

    • .js
    • .json
    • .xml

    Module functions

    Basic provider

    jsonProvider(paths, extensions);
    • paths - array of strings which contains paths to files
    • extensions - array of strings which contains extensions of files from which you want to build an JSON object

    For example, having directory with the following structure:

    Directory structure

    To find all files in ./routing and its sub-directories with extension config.js you can use following code:

    jsonProvider(['./routing/**/*'], ['config.js'])
      .then((object) => {})
      .catch((error) => {});

    Configuration Provider

    configJsonProvider(paths, configFile, projectType, extensions);
    • paths - array of strings which contains paths to files
    • configFile - name of main configuration file
    • projectType - project type
    • extensions - array of strings which contains extensions of files from which you want to build an JSON object

    For example, having directory with the following structure:

    Directory structure

    If you want to build configuration object which depends on project type, for example development you can use following code

    configJsonProvider(['./app/config/*'], 'config', 'development', ['xml', 'js'])
      .then((object) => {})
      .catch((error) => {});

    Install

    npm i @brainhubeu/hadron-json-provider

    DownloadsWeekly Downloads

    10

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    13.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • benedyktdryl
    • dluber
    • brainhubeu-devops
    • annalach
    • szymon.morawski
    • dyoda
    • brainhubeu-ci
    • roberthebel