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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@strata-js/util-config

v0.8.4

Published

A simple configuration utility that supports yaml configuration files and environmental substitutions.

Downloads

48

Readme

Strata Config Utility

Configuration loading utility that supports json, and yaml configuration files and environmental substitutions.

Getting Started

import configUtil from '@strata-js/util-config';

interface MyConfig
{
    someSetting : string;
    nestedConfig : {
        host : string;
        port : number;
    }
}

// Load config file. (This will typically happen as early as possible.)
configUtil.load('./config.yml');

// Get config. (This will happen everywhere you need to access the config.)
const config = configUtil.get<MyConfig>();

API

load(filePath : string, name : string, options : boolean) : void

  • filePath : string - The location of the config file to load. If not provided, it will use the CONFIG_FILE environment variable.
  • name : string - A name to assign to this config. Allows for multiple config files to be loaded. Defaults to 'default'.
  • options : ConfigLoaderOptions - Options to pass to the config loader. See below for details.

ConfigLoaderOptions

This interface defines the options that can be passed to the load method of the ConfigUtil class.

  • substituteEnvironmentVariables : boolean (optional): A boolean value that indicates whether to substitute environment variables in the configuration file content. If this property is set to true, any environment variables in the configuration file content are substituted with their corresponding values. If this property is not specified, the default behavior is true.
  • mergeIncludes : boolean (optional): A boolean value that indicates whether to merge included configuration files into the main configuration file. If this property is set to true, any configuration files specified in the include property of the main configuration file are merged into the main configuration file. If this property is not specified, the default behavior is true.

Parses the config file specified by filePath. Once parsed, the config is made available under name, or the default value of 'default'.

get<T>(name ?: string) : T

  • name : string - The name assigned to the config during load. If not passed, defaults to 'default'.

Loads the config specified by name, if supplied, otherwise loads the config under 'default''.

set<T>(config : T, name ?: string) : void

  • config : T - The config to set.
  • name : string - The name to assign to the config. If not passed, defaults to 'default'.

Sets the config specified by name, if supplied, otherwise sets the config under 'default''.

delete(name ?: string) : void

  • name : string - The name assigned to the config during load. If not passed, defaults to 'default'.

Deletes the config specified by name, if supplied, otherwise clears the config under 'default''.

clear() : void

Clears all configs.