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

confyglot

v0.1.1

Published

Parse configuration files in toml, yaml, json, etc.

Downloads

3

Readme

Confyglot

Loads your app's configuration files in json, toml, yaml, ini, etc.

⚔️ What's the best format for configuration? Who cares! Stop wading into endless arguments. Let your users decide!

Inspired most recently by release-it's support for various configuration formats.

Usage

npm install confyglot
const confyglot = require("confyglot")

confyglot.load("path/to/myProject/someDirectory/", {
  root: "path/to/myProject/", // Build up a cascading configuration up to a project root
  configPrefix: ".myConfig",  // Look for .myConfig.json, .myConfig.yaml, .myConfig.yml, etc.
  defaults: {
    bestFileInDirectory: "info.txt", // Default values to be overridden
  },
}).then((config) => {
  console.log("Loaded configuration:", config);
}).catch((error) => {
  console.error("Failed with error:", error)
});

Feature Overview

Normalization

Various formats have various support for data types like date, numbers(!), and null. By default, Confyglot tries to normalize the output configuration so that you can work with the same JS object shape regardless of which configuration format was used.

💡 You can even force any configuration format to have homogenous arrays like TOML does.

Cascading Configurations Across Directories

Subdirectories might want to override some of the properties of a parent directory's configuration. Let's call this "cascading". Confyglot can cascade files at each level in a directory tree up to a certain project root. You can also provide a default configuration that other configurations can override.

Schema Validation

You can have Confyglot check every loaded configuration against a JSON Schema you provide.

TypeScript

The Confyglot class is generic, so you can specify the type of your configuration that you expect to load. This is most useful when combined with JSON schema validation.

Caveats

General

Confyglot is currently in pre-1.0 development. Its API may change. Also, it is currently very aggressive with throwing exceptions on malformed user configurations. After more usage we'll see if we might want to tone this down.

YAML

⚠️ For some reason, yaml might turn these property names lowercase: "False", "True", and "Null". Not sure in what other cases this might happen, but I would avoid using keywords as field names in your configuration schema for now.