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

@brainstack/config

Package Overview
Dependencies
Maintainers
4
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brainstack/config

A Micro Config Manager Package

latest
npmnpm
Version
1.0.158
Version published
Weekly downloads
7
-56.25%
Maintainers
4
Weekly downloads
 
Created
Source

@brainstack/config

A Micro Config Manager Package

Installation

Install the package using npm:

npm install @brainstack/config

Usage

To use the ConfigManager and ConfigManagerIntegration provided by this package, follow these steps:

  • Import the required interfaces and functions:
import { ConfigManager, ConfigManagerIntegration } from '@brainstack/config';
  • Create an integration that implements the ConfigManagerIntegration interface:
const myIntegration: ConfigManagerIntegration<MyValueType> = {
  get(key: string): MyValueType | undefined {
    // Your implementation to retrieve the value for the key
  },
  set(key: string, value: MyValueType): void {
    // Your implementation to set the value for the key
  },
  remove(key: string): void {
    // Your implementation to remove the value for the key
  },
};
  • Create a ConfigManager instance using the createConfigManager function:
const configManager: ConfigManager<MyValueType> = createConfigManager(myIntegration);
  • Now you can use the configManager to interact with your configuration values:
// Get a configuration value
const value = configManager.get('myConfigKey');

// Set a configuration value
configManager.set('myConfigKey', newValue);

// Remove a configuration value
configManager.remove('myConfigKey');

Example

Here's an example of how you can use the @brainstack/config package:

import { ConfigManager, ConfigManagerIntegration, createConfigManager } from '@brainstack/config';

// Define an integration
const myIntegration: ConfigManagerIntegration<number> = {
  get(key: string): number | undefined {
    // Implementation to retrieve the value for the key
  },
  set(key: string, value: number): void {
    // Implementation to set the value for the key
  },
  remove(key: string): void {
    // Implementation to remove the value for the key
  },
};

// Create a ConfigManager instance
const configManager: ConfigManager<number> = createConfigManager(myIntegration);

// Use the configManager to get, set, and remove configuration values
const value = configManager.get('myConfigKey');
configManager.set('myConfigKey', newValue);
configManager.remove('myConfigKey');

Contributing

Contributions are welcome! If you would like to contribute to this module, please follow these guidelines:

Fork the repository
Create a new branch for your changes
Make your changes and commit them with descriptive commit messages
Push your changes to your fork
Submit a pull request

License

This module is released under the MIT License.

Keywords

brainstack

FAQs

Package last updated on 11 Dec 2024

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