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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pgm-settings

v0.1.2

Published

Get program settings and merge json documents

Readme

Module: pgm-settings

This is a node module to retrieve program settings from various json document sources. The source objects are merged into a single node object. Any node object can be used as a set of default parameters, thus allowing setting collections to be chained.

The source json documents may contain C/C++ style comments that are removed before parsing.

The getProgramSettings({options}) is an async function that can also return a node promise.

Configuration Sources

  • default settings object
  • specified json file
  • program environment variable
  • program startup argument

Usage

const getSettings = require('pgm-settings').getProgramSettings;
var theSettings = await getSettings({options})

The working function in the module is getProgramSettings({options}). The entry point for the module is an un-named async function that calls getProgramSettings().

The Options:

Option = name of option Type = typeof option Seq = processing sequence Description = purpose of option

| OPTION | TYPE | SEQ | DESCRIPTION | |--|--|--|--| | default: | object | 1 | default configuration object | | file: | string | 2 | A filepath to a json file | | env: | string | 3 | The environment variable name | | arg: | string | 4 | The program arguement name | | argenv: | string | 5 | Composite env/arg name |

If the {options} is empty, then the following is assumed:

env: 'SETTINGS'       env.SETTINGS can be a filepath or json document
arg: 'settings'       parsed as --settings=filepath
                      or --settings filepath

The argenv: argument is ignored if either env: or arg: are specified.

env = argenv.toUpperCase()
arg = argenv.toLowerCase()

JSON Comments - C/C++

Source json files may have C/C++ style comments. The comments are removed before the json document is parsed.

/* A C style comment
   that supports multiple lines.
*/
// A C++ comment that extends to current end-of-line.

Example Files - for your own tests

mytest.js
settings-env.json
settings-file.json
settings.json

Mocha Test Suite: (npm test)

test/testing.js		// the regression test file
test/settings-arg.json	// configuration file for program argument testing
test/settings-env.json	// configuration file for program environment testing
test/settings-file.json	// configuration file for options {file: filename.json} testing

Testing getProgramSettings
    ✓ No Configurations Supplied
        getProgramSettings()
    ✓ File Configuration Supplied
        getProgramSettings({file:'settings-file.json'})
    ✓ Default Configuration Supplied
        getProgramSettings({default:{object}})
    ✓ Default+File Configuration Supplied
        getProgramSettings({default:{object},file:'settings-file.json'})
    ✓ Environment Default SETTINGS:settings-env.json Configuration Supplied
        process.env[SETTINGS]='settings-env.json';
        getProgramSettings();
    ✓ Environment Default SETTINGS:<json-document> Configuration Supplied
        process.env[SETTINGS]='{a json document}';
        getProgramSettings();
    ✓ Environment NODE_SETTINGS:settings-env.json Configuration Supplied
        process.env[NODE_SETTINGS]='settings-env.json';
        getProgramSettings({env:'NODE_SETTINGS'})
    ✓ Environment NODE_SETTINGS:<json-document> Configuration Supplied
        process.env[NODE_SETTINGS]='{a json document}';
        getProgramSettings({env:'NODE_SETTINGS'})
    ✓ Program Arg: --settings=settings-arg.json Configuration File
        process.argv.push('--node_settings=settings-arg.json');
        getProgramSettings({arg:'node_settings'})
    ✓ Program argenv: Node_Settings - Combined Configurations
        getProgramSettings({argenv:'Node_Settings'})
        // implies env:'NODE_SETTINGS' and arg:'node_settings'

Support

You can use github resources to help resolve issues.

The author email is not read on a regular basis.