Socket
Book a DemoInstallSign in
Socket

@brainhubeu/hadron-json-provider

Package Overview
Dependencies
Maintainers
5
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brainhubeu/hadron-json-provider

Hadron json provider module

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
Maintainers
5
Weekly downloads
 
Created
Source

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) => {});

Keywords

hadron

FAQs

Package last updated on 04 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts