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

giffo-config

v0.0.3

Published

giffo's config method for node.js

Downloads

9

Readme

##giffo-config

My node.js config method, a small module that reads the file and presents a nice object.

After dealing with the annoyance of xml config files in my java days I wanted the old style of window's style key=value, json-based config files just doesn't do it for me.

a config file might look like this:

# a nice comment
// another comment, ever statement on it's own line.
session.expire = 45
session.redis.password = "a string password"
session.redis.host = "392.329329.32.323";
superduper = "awesome"
test.array = hello, this, is a ,test, of, an , array
test.boolean = true

usage:

var config = require("giffo-config")("default.conf");

config("session.redis.password"); // returns "a string password"
config("session"); // returns the session object
config("session.expire"); // ?todo?returns the number 45 and not a string

or get the object entirely in a single fetch:

var configObj = require("giffo-config")("config-test-file.conf")(); 

console.log(configObj.session.store);

or a more traditional presentable/verbose method (not writing require("giffo-config")) if using more than a single config file etc.

var Config = require("giffo-config");

var appConfig = new Config("app.conf");
var serverConfig = new Config("server.conf");

var favColor = appConfig("favcolor");
var serverTimeouts = serverConfig("timeout");

this module a read only, there is no mechanism to save changes to the config file to disk.

number, boolean and array data-types are converted from the string to their relevant type. putting quotes around a value does not convert.

example: server.port = "4532"

results in 4532 in the string datatype

server.port = 4223

results in a number datatype


this would cause an error, password attempted to access it as an object when it was initially assigned as a string.

password = "hello"
password.saltlen = 24
password.keylen = 40
password.iterations = 4000