Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@humanwhocodes/config-array

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humanwhocodes/config-array

Glob-based configuration matching.

  • 0.10.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31M
decreased by-5.04%
Maintainers
1
Weekly downloads
 
Created

What is @humanwhocodes/config-array?

The @humanwhocodes/config-array package is designed to manage and process arrays of configuration objects. It allows for the easy manipulation and conditional application of configurations based on specific criteria. This package is particularly useful for tools that need to load and use multiple configurations, possibly with overrides or environment-specific settings.

What are @humanwhocodes/config-array's main functionalities?

Loading and processing configuration arrays

This feature allows for loading configurations from multiple sources, including JavaScript and JSON files. The configurations are processed and can be accessed programmatically.

const { ConfigArray } = require('@humanwhocodes/config-array');

const config = new ConfigArray({
  files: ['./config1.js', './config2.json'],
  baseDirectory: process.cwd()
});

config.load().then(() => {
  console.log('Configurations loaded');
});

Conditional configuration

This demonstrates how to add conditional configurations based on criteria such as the environment. It allows for dynamic selection of configurations at runtime.

const { ConfigArray } = require('@humanwhocodes/config-array');

const config = new ConfigArray();

config.add({
  name: 'development',
  criteria: { env: 'development' },
  options: { debug: true }
});

config.add({
  name: 'production',
  criteria: { env: 'production' },
  options: { debug: false, optimize: true }
});

const envConfig = config.find({ env: process.env.NODE_ENV });
console.log(envConfig.options);

Other packages similar to @humanwhocodes/config-array

Keywords

FAQs

Package last updated on 20 Jul 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc