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

@aery/mlc

v1.4.4

Published

Module that loads configs. Pretty self-explanatory

Downloads

35

Readme

(Character: Tohru from Miss Kobayashi's Dragon Maid)

A better way to load your configuration files

Motivation

I needed a module to save me from having to write the same snippets of code in every project that required a config. There already existed many modules that drastically reduced the amount of code I would have to write. But I often still found myself in very simmilar situations: Like writing snippets to generate default configs. Not to mention anyting to do with directories. So that's why I made this neat little module. I hope you are able to get a simmilar amount of value from it as I

Features

  • Simple, load your configs with a single line of code
  • Powerful, read and write both files and directories with defaults
  • Flexible, create support for formats of your needs
  • TypeScript, pre-packaged type definitions
  • JSDocs, together with TS type definitions enables helpful code completion in modern IDEs

Documentation

Examples

Reading a raw text file

import * as mlc from "@aery/mlc";

const file: mlc.ConfigFile = await mlc.file("raw.txt") // Defaults to RawFormat format by default
    .read();

file.content;

Reading a JSON file

import * as mlc from "@aery/mlc";

const file: mlc.ConfigFile = await mlc.file("config.json") /* Associates json files with
                                                              JSONFormat format by default */
    .defaults({
        ip: "127.0.0.1",
        port: 1337
    }) // What content should default to when reading
    .read({ write_if_defaulted: true }); // Write if content was defaulted in any way after reading

file.content;

Writing a raw text file

import * as mlc from "@aery/mlc";

const file: mlc.ConfigFile = mlc.file("foo.txt"); // Defaults to RawFormat format by default

file.content = "bar";

file.write();

Reading a directory

import * as mlc from "@aery/mlc";

const directory: mlc.ConfigDirectory = await mlc.directory("recipies", new mlc.formats.JSONFormat())
    .defaults({
        "water.json": {
            steps: [ "Pour water" ]
        },
        "cereal.json": {
            steps: [
                "Pour cereal FIRST",
                "THEN pour milk"
            ]
        }
    }) // What the ConfigDirectory's ConfigFiles' content should default to when reading
    .read();

const contents: object = directory.contents();

contents["water.json"];
contents["cereal.json"];

Compiling

npm install --only=dev
npm run-script compile

Testing

npm install --only=dev
npm run-script test