New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

configloaderjs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configloaderjs

A package for managing environment variables and configuration loading

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Package Name

Package Name is a powerful package for handling configurations and command line arguments in your Node.js applications.

Installation

You can install the package using npm:

npm install package-name

Usage

Loading Configuration

To load the configuration from an environment file, use the loadConfig function:


const { loadConfig } = require('package-name');

const config = loadConfig();

console.log(config);

const { getCommandLineArguments } = require('package-name');

const args = getCommandLineArguments();

console.log(args);
This will load the configuration from the environment file and return an object containing the key-value pairs.
Getting Command Line Arguments

To retrieve the command line arguments, use the getCommandLineArguments function:

const { getCommandLineArguments } = require('package-name');

const args = getCommandLineArguments();

console.log(args);

This will return an object containing the command line arguments passed to your Node.js application. Parsing Configuration Files

To parse configuration files, use the parseConfig function:

const { parseConfig } = require('package-name');

const configFile = 'config.ini';

parseConfig(configFile)
  .then((parsedConfig) => {
    console.log(parsedConfig);
  })
  .catch((error) => {
    console.error(error);
  });

This function accepts a single file location or an array of file locations. It will parse the specified configuration file(s) and return an object containing the parsed configurations. Examples Example 1: Loading Configuration

const { loadConfig } = require('package-name');

const config = loadConfig();

console.log(config);


Output:

{ key1: 'value1', key2: 'value2' }

Example 2: Getting Command Line Arguments

javascript

const { getCommandLineArguments } = require('package-name');

const args = getCommandLineArguments();

console.log(args);

Output:

[ 'arg1', 'arg2', 'arg3' ]

Example 3: Parsing Configuration Files

javascript

const { parseConfig } = require('package-name');

const configFiles = ['config.ini', 'config.json'];

parseConfig(configFiles)
  .then((parsedConfig) => {
    console.log(parsedConfig);
  })
  .catch((error) => {
    console.error(error);
  });

Output:

{
  'config.ini': {
    SECTION: { key1: 'value1', key2: 'value2' }
  },
  'config.json': {
    key1: 'value1',
    key2: 'value2'
  }
}

License

This package is licensed under the MIT License.

Keywords

environment

FAQs

Package last updated on 28 May 2023

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