npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

config-sets

v3.0.0

Published

Easily configure the app in real-time.

Readme

Config Sets

Easy app configure in real time.

📚 Table of contents


✨ Features

  • Read and write configuration settings to a config-sets.json file.
  • Handle command-line arguments for configuration settings.
  • Watch for changes to the configuration file and update settings in real time.
  • Easy to use and integrate into Node.js applications.
  • Part of the 'conextra' framework.
  • Uses the 'data-context' module for data management.
  • Supports metadata and comments in JSON files.
  • Extended JSON parsing for incremental updates.
  • MIT License.

📋 Description

This Node.js module manages configuration settings by reading from and writing to a config-sets.json file. It handles command-line arguments and watches for changes to the configuration file. It allows you to create applications that can be configured in real time. This module is part of the 'conextra' framework, which is a simple and easy-to-use single-page application (SPA) framework. You have to try it! A different solution than MVC (model–view–controller).

Please note, this version is not backward compatible with version 2.x Please note that JSON string is not 100% compatible. It has been extended to allow for incremental updates of JSON files. Added the ability to include metadata and comments. Parsing of JSON files is enabled.


📦 Installation

To install the module, use npm:

npm install config-sets

🚀 Usage

Basic Usage

To use the module, require it in your script and call the configSets function:


const configSets = require('config-sets');

const config = configSets({ 
    '-metadata-key1': ' key1 comment ',
    key1: 'value1', 
    '-metadata-key2': ' key2 comment ',
    key2: 'value2' 
});

const moduleConfig = configSets('moduleName', { key1: 'value1', key2: 'value2' });

console.log(config);

config.on('key1', function (ev) { console.log(ev); return true; });

file: config-sets.json

/* Configuration settings for application. */
{
  /* Set to true to use production settings, */
  /* false for development settings. Default is true. */
  "isProduction": true,
  /* Settings used in production mode. */
  /* These settings are saved to "config-sets.json" file. */
  "production": {
    /* key1 comment */
    "key1": "value1",
    /* key2 comment */
    "key2": "value2",
    "moduleName": {
        "key1": "value1",
        "key2": "value2"
    }
  },
  /* Settings used in development mode. */
  /* These settings are not saved to file and are created from production settings. */
  /* You can override these settings using command line arguments. */
  /* Set only the settings you want to change. */
  "development": {}
}

Command-Line Arguments

You can pass configuration settings via command-line arguments:

node index.js --key1=value1 --key2=value2

node index.js --help

Watching for Changes

The module watches the config-sets.json file for changes and updates the configuration settings accordingly. This uses the 'data-context' module. Read more about how to use it.

config.on('key1', function (ev) { console.log(ev); return true; });

🧪 Testing

You can test config-sets on your system using this command:

node ./node_modules/config-sets/index.test

or in the config-sets project directory:

npm test

🛠️ API Reference

Main Function

configSets(configModuleName, defaultConfigSettings)

  • configModuleName (optional): The name of the module to set or update configuration settings for.
  • defaultConfigSettings: The default configuration settings.

Returns the current configuration settings.

Static Properties

  • configSets.isProduction: Indicates if the environment is production.
  • configSets.production: Contains production-specific configuration settings.
  • configSets.development: Contains development-specific configuration settings.
  • configSets.enableFileReadWrite (default: true): Determines if changes to the configuration should be saved automatically.

Helper Functions

assign(target, source, overwriteChanges)

  • target: The target object to merge properties into.
  • source: The source object containing properties to merge.
  • overwriteChanges (optional): A boolean indicating whether to overwrite existing properties in the target object.

Merges source objects into a target object.

arg_options()

Parses command-line arguments into an object.

Returns an object containing the parsed command-line arguments.

print_help()

Prints the help message.


📜 License

This project is licensed under the MIT License.

Copyright © Manuel Lõhmus