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

sl-config-loader

v0.0.3

Published

recursively load config files

Downloads

33

Readme

sl-config-loader

v0.0.1

Install

slnode install sl-config-loader

Example

Given a nested structure of directories and config files:

/my-project
  config.json
  /my-resource
    config.json
    /my-sub-resource
      config.json

The sl-config-loader recursively loads and caches all config.json files.

var ConfigLoader = require('../');

var options = {
  'filename': 'config.json', // default config.json
  'envFile': 'config.env.json', // default config.env.json
  'envVar': 'NODE_ENV', // default NODE_ENV
  'ignore': ['images', '.git', /\^.*+/], // default null
  'ttl': 3600 // in seconds, default 3600
};

var configLoader = ConfigLoader.create('path/to/project/root', options);

configLoader.load(function (err, config, cache) {
  Object.keys(config).forEach(function (path) {
    // config.json at the given path
    console.log(config[path]);
  });
});

Usage

Load config files recursively and return them in a dictionary. Each config is keyed by the path of its parent directory.

Env File

Overrides the config based on the current NODE_ENV.

Runtime Consistency

It is safe/performant to call ConfigLoader.load during http requests and other latency sensitive operations.

The sl-config-loader is designed to load configuration that changes at runtime. To support this, the loader caches results for a specified ttl (time to live) and returns that result even if a config file has changed. Once the ttl runs out for a given config root, the loader checks the files last modified time (mtime) and compares it to the cache's last modified time. If the file has changed the new file is loaded from disk. The purpose of this complex checking is to support config loading in latency sensitive operations (eg. handling an http request).