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

huwsettings

v0.2.0

Published

Simple settings parser

Downloads

2

Readme

HUWSettings

HUWSettings is a library for loading settings files with a path-inspired system for overriding and extending settings, support for environment and state variables and conditional settings documents. The functionality is best explained by example.

lib =
  huwsettings: require 'huwsettings'
lib.huwsettings.load ['settings.default.yaml', 'settings.yaml', 'settings.env.yaml'], (error, settings)->
  console.log JSON.stringify settings, null, 2

That snippet loads the following files in sequence:

settings.default.yaml

data_dir: data
value_turning_multiple: 10
tmp_dir: tmp
complex:
  - name: hello
    age: 12
  - name: world
    age: 20
foo:
  bar: bar
  baz: baz
some_dirs:
  - data/sample
replace_this_list:
  - 12
  - 56

settings.yaml

# Simple attribute replacement
data_dir: awesome_data
foo/bar: hello world
# Add new elements and mix and match flat & nested structure
arbitrary/number: 56
arbitrary/text: hello
arbitrary/complex:
  some: info
  about: setting
# The items in this array will be appended to the default
# items.
some_dirs/:
  - data/sample
# The value in the default settings file is not an array
# but will be wrapped in one to allow append.
value_turning_multiple/:
  - 20
  - 5
# Without a trailing slash the array will be replaced.
replace_this_list:
  - 120
  - 560
# Appending an object
complex/:
  name: hugo
  age: 30
# Add the attribute valid to all objects in complex
complex//valid: you bet
# Overwrites are possible within one file
some:
  conf: foobar
some/conf: necktie
obj: 2
# Add an attribute to all top level elements
/valid: value

settings.env.yaml

---
# If we're using headers then every document needs a header.
# If the first document doesn't actually have a header then
# a leading document is needed, now it's just included as
# an example
state:
  some_value: foobar
  editor: $EDITOR
---
shell: $SHELL
editor: <editor
foo/baz: $LC_CTYPE
state_value: <some_value
literal: $$literal string starting with a dollar sign
another_literal: <<literal string starting with a less than sign
your_shell:
  extra_comment: No comment
---
conditions:
  - value: $SHELL
    contains: zsh
state:
  known_shell: yes
---
your_shell/comment: "You are running zsh, good for you!"
---
conditions:
  - value: $SHELL
    is: /bin/bash
state:
  known_shell: yes
---
your_shell/comment: "You are running bash, good for you!"
---
conditions:
  - is_set: <known_shell
    negate: yes
---
your_shell/comment: "I don't know what shell you're running, but whatever works for you."
---
conditions:
  - is_set: <known_shell
---
your_shell/extra_comment: "I'm glad to see that you're running a shell that I know how to use."

End result


data_dir: "awesome_data"
value_turning_multiple: 
  - 10
  - 20
  - 5
tmp_dir: "tmp"
complex: 
  - 
    name: "hello"
    age: 12
    valid: "you bet"
  - 
    name: "world"
    age: 20
    valid: "you bet"
  - 
    name: "hugo"
    age: 30
    valid: "you bet"
foo: 
  bar: "hello world"
  baz: "sv_SE.UTF-8"
  valid: "value"
some_dirs: 
  - "data/sample"
  - "data/sample"
replace_this_list: 
  - 120
  - 560
arbitrary: 
  number: 56
  text: "hello"
  complex: 
    some: "info"
    about: "setting"
  valid: "value"
some: 
  conf: "necktie"
  valid: "value"
obj: 2
shell: "/bin/zsh"
editor: "mate -w"
literal: "$literal string starting with a dollar sign"
another_literal: "<literal string starting with a less than sign"
state_value: "foobar"
your_shell: 
  extra_comment: "I'm glad to see that you're running a shell that I know how to use."
  comment: "You are running zsh, good for you!"