New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@brainstack/config

Package Overview
Dependencies
Maintainers
0
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

  • 1.0.158
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by200%
Maintainers
0
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:

  1. Import the required interfaces and functions:
import { ConfigManager, ConfigManagerIntegration } from '@brainstack/config';
  1. 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
  },
};
  1. Create a ConfigManager instance using the createConfigManager function:
const configManager: ConfigManager<MyValueType> = createConfigManager(myIntegration);
  1. 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

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

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