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

conar

v1.0.3

Published

produces key-value objects from combined config file/argv/env values.

Downloads

4

Readme

Conar Build Status

conar (pronounced like the name connor) provides a quick, customizable way to combine environment, argument, and configuration file values at runtime into a configuration object.

api

conar supports a few different things:

  • (opts:object):
    creates an instance of conar with options. these options are currently only useful for test hooks; it supports:
{
  env:{},  // an environment object to mock out process.env
  arg: [] // an argument object to mock out process.argv
}
  • .env:number:
    see order() method below; provides support for ordering the parsing engine different; represents the env parser

  • .arg:number:
    see order() method below; provides support for ordering the parsing engine different; represents the arg parser

  • .config:number:
    see order() method below; provides support for ordering the parsing engine different; represents the config parser bengreenier/lconf

once you've created an instance, that instance has the following api methods:

  • parse(file:string, [regex:RegExp]):
    parse a file using bengreenier/lconf for configuration. supports json, yaml, yml, and js (with module.exports = {};) if file is a directory, all files inside the directory will be included. if regex is given, file (if actual file) or all files in directory (if file is a directory) will be compared against regex, and added if regex.test(filePath) returns true.

  • order(first:number, second:number, third:number):
    set the order for parsing; takes one of the .<source> parameters from off conar. parsing happens in the order first<-second<-third where <- indicates overwrite

  • defaults(default:object):
    adds default values for certain properties; when parsed, these will be overriden by any active parsers

  • config(key:string):
    blacklists a key from being parsed by this source

  • config(bool:boolean):
    prevents this sources parser from being run at all (disables it)

  • arg(key:string):
    blacklists a key from being parsed by this source

  • arg(bool:boolean):
    prevents this sources parser from being run at all (disables it)

  • env(key:string):
    blacklists a key from being parsed by this source

  • env(bool:boolean):
    prevents this sources parser from being run at all (disables it)

  • suppress([bool:boolean]):
    when set, any exceptions that would normally be thrown by parsers will not be thrown. bool is optional, defaults to true

  • opts():
    this call does the actual processing, and returns an object.

  • log(func:function):
    test hook for writing some internal logging info; should be given a function which will be called with one argument. (hint: console.log)

all methods can be chained, unless specifically indicated otherwise (like opts()).

examples

var conar = require('conar');
var config = conar().opts(); // returns all arguments parsed via command line
var conar = require('conar');
var config = conar().defaults({port:3000}).opts(); // sets a default value port to 3000
var conar = require('conar');
var config = conar()
              .env("port") // whitelist port environment variable
              .parse("config.json") // parse some config file
              .defaults({port: 1337}) // set a default port
              .opts(); // do the work, get an object
var conar = require('conar');
var config = conar()
              .env("port") // whitelist port environment variable
              .env("prod") // whitelist prod environment variable
              .arg("prod") // blacklist prod argument (can't be set like --prod)
              .config(false) // disable config parsing altogether
              .defaults({port: 1337}) // set a default port value to 1337
              .opts(); // do the work, get an object

hopefully you get the idea.